Difference between revisions of "IF Directive"

From Recital Documentation Wiki
Jump to: navigation, search
Line 43: Line 43:
 
<code lang="recital">
 
<code lang="recital">
 
#IF OS() = "Windows Servers"
 
#IF OS() = "Windows Servers"
   dirterm = "&#092;"
+
   dirterm = "\"
 
#ELIF OS() = "Linux Servers"
 
#ELIF OS() = "Linux Servers"
 
   dirterm = "/"
 
   dirterm = "/"

Revision as of 14:24, 17 March 2009

#IF…#ENDIF

Class

Applications


Purpose

Compiler directives to allow inclusion or exclusion of source code based on a condition


Syntax

#IF <expN1> | <expL1>

<statements1>

[#ELIF <expN2> | <expL2>

<statements2>…

#ELIF <expNN> | <expLN>

<statementsN>]

[#ELSE

<statements_else>]

#ENDIF


See Also

COMPILE, #DEFINE, DO, DO CASE, IF, #IFDEF, #INCLUDE, #UNDEF, SET COMPILE, SET DEVELOPMENT


Description

The #IF compiler directive can be used to allow inclusion or exclusion of source code based on a condition. The condition can be a numeric expression, <expN1> or any valid expression evaluating to a logical true (.T.) or false (.F.), <expL1>, and is evaluated at compile time. If the <expL1> evaluates to true or the <expN1> evaluates to a nonzero value, the <statements1> that follow are included in the compiled program file and the compilation continues after the #ENDIF. The <statements1> can be any valid Recital 4GL commands. If the <expL1> evaluates to false or the <expN1> evaluates to zero, the <statements1> are excluded and any included #ELIF directives are evaluated in turn in a similar way. If a #ELIF condition evaluates to a non-zero value or to true, the statements that immediately follow are included in the compiled program file and the compilation continues after the #ENDIF. If no #ELIF directives are specified, or if they all evaluate to zero or to false, a check is made for a #ELSE directive and its <statements_else> included in the compiled file if it exists.

This directive can only be used in compiled programs.


Example

#IF OS() = "Windows Servers"
  dirterm = "\"
#ELIF OS() = "Linux Servers"
  dirterm = "/"
  set filecase on
#ELIF OS() = "OpenVMS Servers"
  dirterm = "]"
#ELSE
  dirterm = "/"
  set filecase on
#ENDIF


Products

Recital Database Server, Recital Mirage Server, Recital Terminal Developer