|
Post by Johnc on Jun 2, 2018 17:01:24 GMT
When using the "Relist Row feature", all the line numbers are relisted into a tidy 1, 2, 3, etc... However, the goto macro line # is not changed automatically to reflect the change. Is this normal or am I missing something? Thanks a lot!
|
|
|
Post by Steve on Jun 2, 2018 23:47:50 GMT
Hi John, When MMM is playing back a macro it runs each line of the macro sequentially from the first line to the last. The line numbers at the start of the macro line are really just a visual representation for the macro author. The line numbers on the macro line are not used by the macro at run time. The true line number of the macro line is it's actual position in the macro list.
1 | RUN ACTION | | | | DEFINE INTEGER VARIABLE | %INTEGER%::+1 1 | RUN ACTION | | | | DEFINE STRING VARIABLE | %STRING1%::c:\temp\output_hold_%integer%.txt 1 | IF | FILE | %string1% | NOT EXIST | RUN VIA CMD /C | echo %clipboard%-%date%-%time%>>%string1% 1 | RUN ACTION | | | | WAIT SECONDS | 6 1 | RUN ACTION | | | | GOTO MACRO LINE | 1 This macro example has all the macro line numbers set to 1. This macro will still run and work as expected. The last macro line, the GOTO action, points to GOTO MACRO LINE 1. Line number 1 is the first macro line, the RUN ACTION DEFINE INTEGER line. To answer your question, the macro relist changes the value of the macro line, but doesn't change any other values. GOTO line numbers have to reflect the true line number you would like to go to. I hope this helps. Regards, Steve.
|
|
|
Post by Johnc on Jun 3, 2018 0:13:03 GMT
Wow, thanks so much for the explanation Steve! I did use duplicated line numbers as I had to insert a few lines before but was too lazy to change all the line numbers (before I found the Relist Row button), and it worked! Now I understand how the GOTO works! No wonder my code was causing so much problems as I was debugging it! Thanks again for providing such an advanced tool! Excellent work Steve!
|
|
|
Post by Johnc on Jun 3, 2018 0:35:05 GMT
Oh... if I have a few comment lines starting with * |, are they counted as macro lines? I am guessing not... please confirm. Thanks once again Steve!
|
|
|
Post by Steve on Jun 3, 2018 1:57:01 GMT
Hi John, Remarks are not counted as macro lines. Consider this example will remarks: 1 | RUN ACTION | | | | MESSAGE PROMPT | Click ENTER to begin::ENTER to Begin * | Increment Integer + 1 2 | RUN ACTION | | | | DEFINE INTEGER VARIABLE | %INTEGER%::+1 * | Define the file path of STRING1 3 | RUN ACTION | | | | DEFINE STRING VARIABLE | %STRING1%::c:\temp\output_hold_%integer%.txt * | If the file does not exist, create it 4 | IF | FILE | %string1% | NOT EXIST | RUN VIA CMD /C | echo %clipboard%-%date%-%time%>>%string1% * | Wait 2 seconds before continuing 5 | RUN ACTION | | | | WAIT SECONDS | 2 * | Loop with GOTO line 2 6 | RUN ACTION | | | | GOTO MACRO LINE | 2
Note line 6, the RUN ACTION GOTO MACRO LINE 2. This action will loop to bring the macro back to this line '2 | RUN ACTION | | | | DEFINE INTEGER VARIABLE | %INTEGER%::+1'. Remarked lines are totally ignored when using GOTO MACRO LINE.
However, there is an exception to this rule when using the %RETURN% variable. %RETURN% holds the true last macro line number. This number is inclusive of remark lines. Consider this example: 1 | RUN ACTION | | | | MESSAGE PROMPT | Click ENTER to begin::ENTER to Begin * | Increment Integer + 1 2 | RUN ACTION | | | | DEFINE INTEGER VARIABLE | %INTEGER%::+1 * | Define the file path of STRING1 3 | RUN ACTION | | | | DEFINE STRING VARIABLE | %STRING1%::c:\temp\output_hold_%integer%.txt * | If the file does not exist, create it 4 | IF | FILE | %string1% | NOT EXIST | RUN VIA CMD /C | echo %clipboard%-%date%-%time%>>%string1% * | Wait 2 seconds... 5 | RUN ACTION | | | | WAIT SECONDS | 2 * | Loop with GOTO line 2 6 | RUN ACTION | | | | GOTO MACRO LINE | %RETURN%-8
The value of %RETURN% at macro line 6 (the GOTO action) is 10. It's 10 because there has been 10 true macro lines that have passed to that point. So if we GOTO MACRO LINE %return%-8 or (10-8) we in effect GOTO MACRO LINE 2. Hope this helps. Regards, Steve.
|
|
|
Post by Johnc on Jun 3, 2018 2:02:39 GMT
This is cool and I got it now! Thank you so much once again Steve! MMM is so powerful!
|
|