HPlogo Using NS 3000/iX Network Services: HP 3000 MPE/iX Computer Systems > Chapter 8 NetCI

IF Statement

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

The IF statement controls the execution of a block of commands or a single command depending on whether the expression (or condition) is true.

The IF statement consists of the reserved word IF, an expression (condition), commands, the reserved word ELSE and other commands which are optional, and the reserved word ENDIF.

When NetCI executes an IF statement, the following occurs:

  1. NetCI evaluates the expression which is the condition.

  2. If the condition is true and ELSE is specified, it executes the subsequent commands that follow the condition and skips the commands after ELSE to statements or commands after ENDIF. If the condition is true and ELSE is not specified, it executes the subsequent commands that follow the condition.

  3. If the condition is false and ELSE is specified, it executes the commands after ELSE. If the condition is false and ELSE is not specified, flow control skips to statements or commands after ENDIF.

Syntax

IF expression
commands
[ELSE commands]
ENDIF

Parameters

expression

Specifies the condition that determines whether the commands following it will execute. The expression must be in the following format:

     identifier operator identifier

The identifier is a variable name, numerical value, or known variable (set flag) in NetCI. The operator is an equal sign (=), not equal sign (< >), greater than sign (>), or less than (<) sign.

commands

Specifies the commands to be executed provided the expression (condition) is true.

commands

Specifies the commands following ELSE to be executed provided the expression (condition) is not true. The ELSE statement and commands are optional.

Discussion

You may nest both IF and WHILE statements in script files. A maximum of 20 IF statements and 20 WHILE statements (for a total of 40 statements) may be nested together within the same script file.

Feedback to webmaster