Macros flow control

There are several constructs available for controlling the flow execution, which include conditional statement blocks, several looping constructs and variable assignation. Some example are given in this tutorial. For a complete description, see the section Macros the chapter The KUIP interface in the PAW reference manual.

                                                                                                                   
     Statement                      |     Description                                                                   
                                                                                                                        
 MACRO mname par1=val1 ...          | begin macro  mname                                                                
 EXEC mname par1 par2=val2 ...      | execute macro  mname                                                              
 RETURN                             | end of a macro                                                                    
 READ par                           | read macro parameter  par  from keyboard                                          
 SHIFT                              | control parameters list                                                           
 label:                             | label (must terminate with a colon)                                               
 GOTO label                         | jump to  label                                                                    
 ON ERROR GOTO label                | resume at  label  on error condition                                              
 OF ERROR                           | temporarily deactivate the  ON ERROR GOTO  handling                               
 ON ERROR                           | reactivate the latest  ON ERROR GOTO  handling                                    
 IF logical_expression GOTO label   | conditional statement                                                             
 IF-THEN, ELSEIF, ELSE, ENDIF       | Macro flow control                                                                
 CASE, ENDCASE                      | Macro flow control                                                                
 WHILE-DO, ENDWHILE                 | Macro flow control                                                                
 REPEAT, UNTIL                      | Macro flow control                                                                
 DO, ENDDO                          | Macro flow control                                                                
 FOR, ENDFOR                        | Macro flow control                                                                
 BREAKL                             | Macro flow control                                                                
 EXITM                              | Macro termination                                                                 
 par = arithmetic_expression        | assignment statement                                                              
                                                                                                                        

Conditional statement

MACRO PAWEX06A PAW > exe pawex06a A = 10 Sum of 10 and 1.5 is 11.5 NN = 1.5 KUIP arithmetic is correct. TOT = [A]+[NN] IF [TOT] > 11 THEN MESSAGE Sum of [A] and [NN] is [TOT] AOK = correct ELSE AOK = wrong ENDIF MESSAGE KUIP arithmetic is [AOK]. RETURN

Unassigned variables cannot be substituted by their values.

MACRO PAWEX06B PAW > exe pawex06b A = 10 Result of sum is 10+[XX] NN = 1.5 TOT = [A]+[XX] MESSAGE Result of sum is [TOT] RETURN

Example for CASE labels with wildcards

MACRO PAWEX06C PAW > exe pawex06c paw.tex CASE [1] IN paw.tex is a LaTex file. (*.f, *.for) TYPE = FORTRAN (*.c) TYPE = C (*.p) TYPE = PASCAL (*.tex) TYPE = LaTex (*) TYPE = UNKNOWN ENDCASE MESSAGE [1] is a [TYPE] file. RETURN


Last update: 96/05/24 17.18
Olivier.Couet@Cern.Ch