Question Difference Between If And &if?

Hello guys

I am new here.

This is just a simple question, but what is the difference between if and &if.
Or basically what does '&' do?

Any replies will be appreciated.
-caloykoko
 

davidvilla

Member
IF is normal IF condition that you see in other programming languages. It will be compiled during compile-time and evaluated during run-time.
&IF is a pre-processor statement. It will be evaluated during compile-time. Only if it evaluates to TRUE, the following code will be compiled.
 

Osborne

Active Member
Quick answer - &IF is resolved at compile time, whereas IF is resolved at run time. One useful use of &IF is if a program is run under both TTY and GUI and you want code that is specific to the one but not to the other or would crash the other:
Code:
&IF "{&WINDOW-SYSTEM}" = "TTY" &THEN
    ...
    ...
&ELSE
    ...
    ...
&ENDIF

Code:
&IF "{&OPSYS}" = "UNIX" &THEN
    ...
    ...
&ELSE
    ...
    ...
&ENDIF
 
Top