IF Branches

Navigation:  Appendices > Macro Language > Compiled Code > Compiled Code Samples >

IF Branches

Previous pageReturn to chapter overviewNext page

The compiled code generated by an IF branch is not particularly noteworthy, but it is important to understand it because it is used in the FOR and WHILE loops as well as the SWITCH branch.

 

The basic if-else branch looks like this.

 

if not bCondition

 // do something if true

else

 // do something else if false

endif

 

The above code compiles into :

 

0007 IF_001 @bCondition jne+0002

 

0009 JMP+0001 //ELSE_001

 

0011 ENDF_001

 

Note that if the branching condition is a function call, it is evaluated before the IF_xxx op-code. For example :

 

if MonthOf(Today()) = 1 // january

  // do something if true

else

  // do something else if false

endif

 

compiles to :

 

0007 CALL n001=$0HM()  //Today

0007 CALL n002=$0FH(@n001)  //MonthOf

0007 CALL b001=$0BI(@n002|1)  //EqualN

0007 IF_001 @b001 jne+0002

 

0009 JMP+0001  //ELSE_001

 

0011 ENDF_001

 

This will become very important when we discuss the FOR and WHILE loops.


Topic 108219 updated on 01-Nov-2016.
Topic URL: http://www.qppstudio.net/webhelp/index.html?ifbranches.htm