% @(#)if.mlc 17.1.1.1 (ESO-IPG) 01/25/02 17:43:39 \leftpage \noqualifier \se SECTION./ \es\co IF 20-JAN-1993 KB \oc\su %IF par1 op par2 command_string % execute conditional statement \us\pu Purpose: Execute conditional statement. \up\sy Syntax: IF par1 op par2 command_string (a) \\ \ IF par1 op par2 THEN (b) \ \ \ command_string ELSEIF par1 op par2 THEN \ \ \ command_string \ \ \ ... ELSE \ \ \ command_string ENDIF \ \ys\pa par1,par2 = name of a keyword (with parentheses) or a constant; \\ numerical constants begin with a digit; \\ character constants are enclosed in quotation marks ("). \\ All character strings not enclosed in quotation marks are interpreted as keyword names !!! \ap\pa op = logical operation, may be .EQ. or .NE. or .GE. or .GT. or .LE. or .LT. with the usual meaning (cf. FORTRAN) \ap\pa command_string = a valid MIDAS command line; \\ but remember that the total no. of `tokens' per line is 10, therefore only "short" commands can be used for option (a) \ap\sa See also: Chapter 3 of the MIDAS Users Guide, volume A \as\no Note: Please, note that contrary to FORTRAN the ELSEIF and ENDIF must(\!) be written as one word, i.e. ELSE IF results in an error ... \\ Logical operations can be combined with an .AND. or .OR. (but only a single .AND. or .OR. because we only have max. 10 tokens per command line), see the examples. \on\exs Examples: \ex IF INPUTR(6) .GT. 22.1 GOTO END will result in a branch to the command following the label END: if the element (6) of keyword INPUTR > 22.1\\ \xe\ex \ \\ IF INPUTR(6) .GT. 22.1 THEN\\ \ \ \ WRITE/KEY IN_B \{INPUTR(6)\} \ \ \ WRITE/OUT \{IN_B\} ELSEIF IN_A(3:4) .EQ. "AB" THEN\\ \ \ \ WRITE/OUT "here we are..."\\ ENDIF \xe\ex \ \\ IF INPUTC(1:3) .EQ. "XXX" .OR. INPUTD(1) .LT. 0.0 RETURN we return from this procedure if either condition is true \xe\ex \ \\ IF INPUTI(10) .EQ. 10 .AND. INPUTI(11) .NE. 11 THEN\\ \ \ \ @@ proca \\ ELSE\\ \ \ \ @@ procb \\ ENDIF \xe \sxe