<< Click to Display Table of Contents >> Navigation: 3. Script Language > JXX. - Jump - Instructions > JXX-Commands: "Jump If ..." |
MiniRobotLanguage (MRL)
JRR. Conditional Jump
Jump and Reset Returnstack
Intention
Error-handling in Subroutines. Imagine you have called a subroutine using JSR.
Normally you would return from there using RET. And then continue your script.
Now there is an error or special condition. You want to jump directly to the error-handler in the main-script. Or you want to just re-run the complete script from start?
If you do just that, there will be more and more useless entries on the so called "Return stack". That is the place, where each JSR./GSB. remembers where to jump back in case of a return (RET.). Now comes JRR.
With JRR. you can clear the RET.-Stack and make the robot forget all previous GSB./JSR. Usage is simple, use:
' This will clear the complete Return Stack
JRR.restart
You can also choose to remove only the the last P2-number of entries from the return stack if a number is given for P2.
' ... will only remove the last entry
JRR.restart|1
And then you can just re-run the Script or do whatever is needed.
You can use JRR. on any of the following cases. Note in the case of FEX.-Instructions that you should prefer to use EFX. if you want to stop the enumeration.
• STW. - Description with the "W", or "V"-Option
• ! SCW - Search-Child-Window with the "W", or "V"-Option
• ITW. with the "W", or "V"-Option
• ICW. with the "W", or "V"-Option
• any other of the JIX. - Jumps, when using the ":"-Label Option
• any of the FEX.-Enumeration Instructions, important: use EFX. in that case
Syntax
JRR.P1[|P2]
Parameter Explanation
P1 - Label or Variable that evaluates to a Label.
If it starts with a ":" (colon) a JSR. - Jump SubRoutine (Label) (GOSUB like)
Jump is done instead of the normal JMP. - Jump to Label (GOTO like) Jump..
P2 - if omitted the completed Return Stack is cleared. If a number is given, the
number of entries is been removed from the return stack.
Example
'***********************************************
' Example 1 - without Parameters,
'***********************************************
: $$AAA=10
:restart
JSR.Laba
CAL.$$AAA=3+(9*$$AAA)+2.5
PRT. Resultat ist: $$AAA
END.
:Laba
IVV.§§AAA=10
: §§AAA=9
JRR.restart
EIF.
RET.
ENR.
Remarks
Alternatively you can use JMP.retry|r
Limitations:
-
See also:
• JSR. - Jump SubRoutine (Label)
• JME. - Jump on More or Equal
• JLE. - Jump on Less or Equal