|
Post by philranger on Apr 9, 2021 13:14:26 GMT
Hello!
MMM pro 8.2.0.0
1 | FOR | I | = | 1 TO 5 | NEXT
2 | RUN ACTION | MESSAGE PROMPT | %I%
3 | FOR | NEXT
1st message is "2", not "1" as expected. Anyone else has the same?
Thanks!
|
|
|
Post by Steve on Apr 10, 2021 5:06:33 GMT
Hi philrangerAre you trying to count from 1 to 5? If so start at 0. The first iteration increments the FOR loop %I% counter. 1 | FOR | I | = | 0 TO 5 | NEXT 2 | RUN ACTION | MESSAGE PROMPT | %I% 3 | FOR | NEXT
|
|
|
Post by philranger on Apr 11, 2021 18:26:00 GMT
Thanks! Can you put a for loop inside a for loop, the code below doesn't work...
1 | FOR | I | = | 1 TO 5 | NEXT 2 | FOR | J | = | 10 TO 13 | NEXT 3 | RUN ACTION | MESSAGE PROMPT | I=%I%,J=%J% 4 | FOR | NEXT J 5 | FOR | NEXT I
|
|
|
Post by Steve on Apr 18, 2021 0:41:50 GMT
Hi Phil, Yes you can. Basic FOR LOOPS can be nested but they don't work as your have them in your example. They work more like this: 1 | FOR | I | = | 0 TO 3 | NEXT 2 | RUN ACTION | DEFINE STRING VARIABLE | %parent%::%I% 3 | FOR | I | = | 0 TO 5 | NEXT 4 | RUN ACTION | DEFINE STRING VARIABLE | %child%::%I% 5 | RUN ACTION | MESSAGE PROMPT | Parent=%PARENT%of5 Child=%CHILD%::loop status::1 6 | FOR | NEXT 7 | FOR | NEXT
|
|
|
Post by philranger on Apr 19, 2021 17:21:46 GMT
Thanks Steve, I wouldn't have guessed that alone!
|
|