NET/MASTER Network Control Language (NCL) Reference Manual
PARSE
Verbs
106126 Tandem Computers Incorporated 3–147
Examples
The following example creates (or reassigns values to) the variables &1, &2, and &3
with the values &1=123, &2= 456, and &3=789. A space precedes the numeric value
456 in the second variable, &2; this space occurs in the data string:
PARSE DELIM="," ARGS OPT=ASIS DATA="123, 456,789"
The following example creates (or reassigns values to) the variables &A, &B, &C, and
&D as follows: &A=aaa, &B=bbb, &C=null value, and &D=ccc. The remainder of the
string, “ddd,” is placed in the variable &REST:
PARSE DELIM=":, " VARS=(&A,&B,&C,&D) REMSTR=&REST,
DATA="aaa,bbb, ,ccc,ddd"
The following example creates the variables &1, &2, &3, &4, and &5 with the values
&1=this, &2=is, &3=a, &4=variable, and &5=msg. The blank is the default delimiter,
so any blanks in the message do not appear in the variables:
PARSE ARGS DATA=this is a variable msg.
The following example creates the variables &C1, &C2, &C3, &C4 and places the
values F, R, E, D respectively in each variable:
&FRED="FRED"
PARSE PARSE=NO SEG=1 VARS=(&C1,&C2,&C3,&C4) DATA=&FRED
The following example is a complete NCL procedure that shows another use of the
VARS operand in splitting and skipping text, and placing the resultant data into
specified variables:
APROC: PROCEDURE
PARSE VARS=(&A,*(2),&B(1),&C,&D) REMSTR=&REST,
DATA="AAAA,BBBB,CCCC,DDDD,EEEE,FFFF,NO MORE DATA"
SAY "&A =" &A "&B =" &B "&C =" &C "&D =" &D
SAY "&REST =" &REST
END APROC
In the previous example, the result of displaying the variables &A through &D is:
&A=AAAA
&B=D
&C=EEEE
&D=FFFF
The second and third words of the text are skipped as a result of the operand *(2)
within the VARS string. Only the first character of the fourth word is placed in the
variable &B because this variable specification is followed by (1).
The variable &REST contains NO MORE DATA.