HPlogo System Debug Reference Manual: HP 3000 MPE/iX Computer Systems > Chapter 4 System Debug Command Specifications

IF

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

If condition evaluates to TRUE, then execute all commands in cmdlist, else execute all commands in cmdlist2.

Syntax

   IF condition THEN command 



   IF condition THEN { cmdlist }



   IF condition THEN command1 ELSE command2



   IF condition THEN { cmdlist } ELSE command2



   IF condition THEN command1 ELSE { cmdlist2 }



   IF condition THEN { cmdlist } ELSE { cmdlist2 }

Parameters

condition

A logical expression to be evaluated.

command cmdlist

A single command (or command list) that is executed if condition evaluates to TRUE.

command2 cmdlist2

A single command (or command list) that is executed if condition evaluates to FALSE.

Note that in nested IF-THEN-ELSE clauses, the first ELSE clause always matches the first IF clause. This is different from the conventions of most compilers, and it may not be intuitive. Explicit use of {cmdlists} is recommended in these nested cases.

Examples

   %cmdebug > if [q-3]>[db+4] then c

If the contents of Q-3 are greater than the contents of DB+4, then continue.

   $nmdebug > if (length>20) and (pcsf=a) then {wl "GOT IT"; c}

If the value of the variable length is greater than 20, and the contents of the predefined variable pcsf equals $a, then execute the following from the command list: print the string "GOT IT", then continue.

   $nmdat > if 1 then {if 0 then wl "wee" else wl "willy"} else wl "wonka"

   willy

This example shows a nested IF-THEN-ELSE clause within a cmdlist clause.

Limitations, Restrictions

The interpreter does not parse or analyze the contents of the clauses prior to their execution. Based on the value of the condition, the THEN or ELSE clause is be executed, and the other clause disregarded.

This implies that the clauses may be syntactically illegal, but the errors are not discovered until they are executed.

Note that in the following examples, entire clauses are bogus, but not detected:

   $nmdebug > if TRUE then wl "good" else XXXXXXXXXXXXXXXXXX

   good



   $nmdebug > if FALSE then XXXXXXXXXXXXXXXX else wl "good"

   good
CAUTION: The output format of all System Debug commands is subject to change without notice. Programs that are developed to postprocess System Debug output should not depend on the exact format (spacing, alignment, number of lines, uppercase or lowercase, or spelling) of any System Debug command output.
Feedback to webmaster