GET(ARG.)

GET(ARG.)

Top  Previous  Next

 

The GET(ARG.) statement fetches command line arguments.

 

 

Format

 

GET(ARG. {, argno}) var  {THEN statement(s)} {ELSE statement(s)}

 

 

The GET(ARG.) statement allows a program to retrieve command line arguments. This statement is provided for compatibility with other systems. The !PARSER() subroutine provides a more powerful way to process command arguments.

 

The command line is considered to be formed from a number of tokens separated by spaces. Spaces within quoted strings are treated as part of the string. The GET(ARG.) statement, used without the argno element or with argno less than one, returns the value of the next command line argument in var. Specifying a positive and non-zero value for argno retrieves the specified argument.

 

The THEN and ELSE clauses are both optional. If present, the THEN clause will be executed if the argument is retrieved successfully. The ELSE clause is executed if the argument was not present in the command line.

 

If the program is started using the RUN or DEBUG commands, the argument data is each argument following the program record name. If the program is started by reference to its name within the catalogue, the argument data is everything after the catalogue name.

 

The command arguments and the current position within them are stacked on a per-command processor level basis.

 

 

Examples

 

PROGRAM TEST

  GET(ARG.) A

  GET(ARG.) B

  GET(ARG.) C

  DISPLAY A

  DISPLAY B

  DISPLAY C

END

 

If the above program is executed using the command

RUN TEST PPP "QQQ RRR" SSS

the output would be

PPP

QQQ RRR

SSS

 

The same output would be produced by

RUN BP TEST PPP "QQQ RRR" SSS

or, if the program was catalogued,

TEST PPP "QQQ RRR" SSS

 

 

Changing the program to be

PROGRAM TEST

  GET(ARG., 2) A

  GET(ARG.) B

  DISPLAY A

  DISPLAY B

END

any of the commands above would display

QQQ RRR

SSS

 

 

Use of a construct such as

GET(ARG., 4) ELSE DISPLAY "Insufficient command arguments"

allows a program to check how may arguments have been supplied.