The IF_xxx op-code is part of the compiled code generated when compiling branches and loops in source code. This op-code is used in compiled code to fully represent all of the following: if-else, switch, while, for.
0003 IF_001 @b001 jne+008
The xxx are numbers which are automatically generated by the compiler as the branch/loop stack increases. When the interpreter encounters an IF_xxx op-code, it verifies if the variable to the right of it is true or false.
If the variable to the right is true the interpreter will execute the following lines until it reaches either :
•a JMP telling it by how many lines to jump to reach to the corresponding ENDF_xxx instruction.
•or an ENDF_xxx (where the xxx are the same).
If the variable to the right of the op-code is false then the interpreter will jump by the number of lines indicated after the jne+ op-code (jne stands for "jump if not equal").
Note that only Boolean variables can appear to the right of IF_xxx op-codes. If your source code contains a function call as part of the if :
if WeekdayOf(Today()) == 5 // is today Friday?
then the compiler will break down the call into simpler parts.
0003 CALL n003=Today()
0003 CALL n002=WeekdayOf(@n003)
0003 CALL b001=EqualN(@n002|6)
0003 IF_001 @b001 jne+008
The IF_xxx op-code is thus similar, yet different, from the if source code statement, in the same way as the CALL op-code differed from the calling of a function in source code.
Finally note that the values used for xxx are unique. Even if loop 001 is finished, the compiler will never generate another 001 loop (IF, SWITCH, FOR or WHILE) within the same macro.
Topic 108176, last updated on 18-Apr-2020