Difference between revisions of "IF Directive"

From Recital Documentation Wiki
Jump to: navigation, search
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
=#IF…#ENDIF=
 
 
 
==Class==
 
Applications
 
 
 
 
==Purpose==
 
==Purpose==
 
Compiler directives to allow inclusion or exclusion of source code based on a condition
 
Compiler directives to allow inclusion or exclusion of source code based on a condition
Line 17: Line 10:
 
[#ELIF <expN2> | <expL2>
 
[#ELIF <expN2> | <expL2>
  
<statements2>
+
<statements2>...
  
 
&#035;ELIF <expNN> | <expLN>
 
&#035;ELIF <expNN> | <expLN>
Line 31: Line 24:
  
 
==See Also==
 
==See Also==
[[COMPILE]], [[DEFINE|#DEFINE]], [[DO]], [[DO CASE]], [[IF]], [[IFDEF|#IFDEF]], [[INCLUDE|#INCLUDE]], [[UNDEF|#UNDEF]], [[SET COMPILE]], [[SET DEVELOPMENT]]
+
[[COMPILE]], [[DEFINE|#DEFINE]], [[DO]], [[DO CASE]], [[IF]], [[IFDEF|#IFDEF]], [[INCLUDE|#INCLUDE]], [[SET COMPILE]], [[SET DEVELOPMENT]], [[UNDEF|#UNDEF]]
  
  
 
==Description==
 
==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.
+
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.
 
This directive can only be used in compiled programs.
Line 43: Line 36:
 
<code lang="recital">
 
<code lang="recital">
 
#IF OS() = "Windows Servers"
 
#IF OS() = "Windows Servers"
  dirterm = "\"
+
    dirterm = "\"
 
#ELIF OS() = "Linux Servers"
 
#ELIF OS() = "Linux Servers"
  dirterm = "/"
+
    dirterm = "/"
  set filecase on
+
    set filecase on
 
#ELIF OS() = "OpenVMS Servers"
 
#ELIF OS() = "OpenVMS Servers"
  dirterm = "]"
+
    dirterm = "]"
 
#ELSE
 
#ELSE
  dirterm = "/"
+
    dirterm = "/"
  set filecase on
+
    set filecase on
 
#ENDIF
 
#ENDIF
 
</code>
 
</code>
Line 57: Line 50:
  
 
==Products==
 
==Products==
Recital Database Server, Recital Mirage Server, Recital Terminal Developer
+
Recital Server, Recital  
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Commands]]
 
[[Category:Commands]]
 +
[[Category:Applications]]
 +
[[Category:Applications Commands]]

Latest revision as of 16:56, 11 November 2009

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, SET COMPILE, SET DEVELOPMENT, #UNDEF


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 Server, Recital