HPlogo MPE/iX Commands Reference Manual: HP 3000 MPE/iX Computer Systems > Chapter 4  Command Definition F-K

IF

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

Used to control the execution sequence of a job, UDC, or command file. (Native Mode)

Syntax

IF expression [THEN]

Parameters

expression

Logical expression, consisting of operands and relational operators. The operators listed in Table 4-1 “Logical Operators - The IF Command” may be incorporated in expression.

Table 4-1 Logical Operators - The IF Command

Logical operators:AND, OR, XOR, NOT
Boolean functions and values:BOUND, TRUE, FALSE, ALPHA, ALPHANUM, NUMERIC, ODD
Comparison operators:=, <>, <, >, <=, >=
Bit manipulation operators:LSL, LSR, CSR, CSL, BAND, BOR, BXOR, BNOT
Arithmetic operators:MOD, ABS, * , / , + , -, ^ (exponentiation)
Functions returning strings:CHR, DWNS, UPS, HEX, OCTAL, INPUT, LFT, RHT, RPT, LTRIM, RTRIM, STS
Functions returning integers:ABS, LEN, MAX, MIN, ORD, POS, TYPEOF
Other functions:FINFO, SETVAR

 

The allowed operands are any variable, integer, string, or Boolean constants, and the MPE/iX reserved words are WARN, FATAL, SYSTEM, and OK.

Compound logical expressions can be formed using the AND, NOT, XOR, and OR logical operators, and nested within parentheses.

The THEN keyword is optional. It may be used or omitted and has no effect on the results.

Operation Notes

This command begins an IF block consisting of all the commands after the IF command up to, but not including, the next ELSE. ELSEIF, or ENDIF statement. The ELSE, ELSEIF, or ENDIF must have the same nesting level as the IF statement. Another similar block can follow the ELSE statement.

Nesting of the blocks is allowed to 30 levels so long as IF is used alone. In a case where IF is used with WHILE the total nesting of IF and WHILE blocks cannot exceed 30 levels. Each IF or WHILE block read by the Command Interpreter increments the nesting count even if it resides within a different UDC or COMMAND file.

The ENDIF statement ends the IF block. The logical expression is evaluated and, if the expression evaluates to TRUE, the IF block is executed; if FALSE, the ELSE or ELSEIF block (if one exists) is executed.

NOTE: You may not write an IF construct in such a way that it physically crosses from one user command (UDCs or command files) to another.

Use

This command may be issued from a job, session, program, or in BREAK. Pressing Break has no effect unless expression contains the INPUT evaluator function.

Example

The following job listing illustrates the use of an IF statement with ELSE and ENDIF statements:

 !CONTINUE
!PASXL MYPROG,MYUSL
!IF JCW>=FATAL THEN
! TELL USER.TECHPUBS;COMPILE FAILED
!ELSE
! TELL USER.TECHPUBS;COMPILE COMPLETED
!ENDIF

Related Information

Commands

CALC, ELSE, ELSEIF, ENDIF, WHILE, ENDWHILE, ESCAPE, RETURN

Manuals

Appendix B, "Expression Evaluator Functions"

Feedback to webmaster