[an error occurred while processing this directive]
HP OpenVMS Systems Documentation |
HP OpenVMS DCL Dictionary
F$ELEMENT
Extracts one element from a string of elements. FormatF$ELEMENT (element-number, delimiter, string) Return ValueA character string containing the specified element. Arguments
|
#1 |
---|
$ DAY_LIST = "MON/TUE/WED/THU/FRI/SAT/SUN" $ INQUIRE DAY "ENTER DAY (MON TUE WED THU FRI SAT SUN)" $ NUM = 0 $ LOOP: $ LABEL = F$ELEMENT(NUM,"/",DAY_LIST) $ IF LABEL .EQS. "/" THEN GOTO END $ IF DAY .EQS. LABEL THEN GOTO 'LABEL' $ NUM = NUM +1 $ GOTO LOOP $ $ MON: . . . |
This example sets up a loop to test an input value against the elements in a list of values. If the value for DAY matches one of the elements in DAY_LIST, control is passed to the corresponding label. If the value returned by the F$ELEMENT function matches the delimiter, the value DAY was not present in the DAY_LIST, and control is passed to the label END.
#2 |
---|
$ ! INDEX.COM $ ! $ CHAPTERS = "0,1,2,3,4,5,6,A,B,C" $ NEXT = 0 $ LOOP: $ NEXT = NEXT + 1 $ NUM = F$ELEMENT(NEXT,",",CHAPTERS) $ IF (NUM .NES. ",") $ THEN $ RUN INDEX CHAP'NUM' $ GOTO LOOP $ ENDIF |
This example processes files named CHAP1, CHAP2, ... CHAP6, CHAPA, CHAPB, and CHAPC, in that order. (Zero is included in the CHAPTERS string to initialize the procedure logic.) NEXT is initialized to zero. The procedure enters the loop. In the first iteration, NEXT is incremented to 1 and the result of the F$ELEMENT call is the string "1". The procedure runs the index, chapter 1. In the second iteration, NEXT is incremented to 2 and the result of the F$ELEMENT call is the string "1". The procedure runs the index, chapter 2. Processing continues until the result of the F$ELEMENT call is the delimiter specified in the call.
Previous | Next | Contents | Index |