#IF

Function

Indicates that the commands following are to be compiled when the expression is TRUE. (#IF is a compiler directive.)

Syntax

#IF {txt_lit|num_lit}comparison_operator
{txt_lit|num_lit}

Arguments

txt_lit|num_lit

Any text or numeric literal.

comparison_operator

Any of the following comparison operators:

OperatorDescription
=Equal
!=Not Equal

<>

Not Equal

<

Less than

>

Greater than

<=

Less than or equal

>=

Greater than or equal

Description

Production Reporting has five compiler directives that allow different pieces of Production Reporting code to be compiled, depending on the existence or value of substitution variables (not program variables, such as, string, numeric, or date).

Substitution variables defined automatically for each -DEBUGxxx letter can also be used with the #IF, #IFDEF, and #IFNDEF directives. They can turn entire sections of an Production Reporting program on or off from the command line, depending on the -DEBUGxxx flag.

You can nest #IF, #IFDEF, or #IFNDEF directives to a maximum of 10 levels.

The #IF, #IFDEF, or #IFNDEF directives cannot be broken across program lines.

Table 42 lists the compiler directives.

Table 42. Production Reporting Compiler Directives

Directive

Example

Description

#IF

#IF {option}='A'

Compiles the commands following the #IF directive if the substitution variable option is equal to 'A'. The test is case-insensitive. Only one simple expression is allowed per #IF command.

#ELSE

#ELSE

Compiles the commands following the #ELSE directive when the #IF expression is FALSE.

#ENDIF

#ENDIF

Ends the #IF directive. #ENDIF can also be typed #END-IF (with a hyphen).

#IFDEF

#IFDEF option

Compiles the commands following the #IFDEF directive if the substitution variable option is defined.

#IFNDEF

#IFNDEF option

Compiles the command following the #IFNDEF directive if the substitution variable option is not defined.

Examples

begin-setup 
  ask type 'Use Male, Female or Both (M,F,B)'
end-setup
begin-procedure Main
#if {type} = 'M' 
  ...code for M here
#else
#if {type} = 'F'
  ...code for F here
#else
#if {type} = 'B'  
  ...code for B here
#else
  show 'M, F or B not selected. Report not created.' 
  stop
#endif   ! for B
#endif   ! for F
#endif   ! for M
#ifdef  debug 
  show 'DEBUG:  Cust_num = '  &cust_num  edit  099999
#endif
#ifndef debugB ! DebugB turned on with -DEBUGB on 
  do test_procedure! Production Reporting command line.
#endif

See Also

#DEBUG for information on the -DEBUG command-line flag