PARSE
[SIC\]PARSE [/OptionName1 [Nargmin [Nargmax]]] ... [/OptionNameN
...]
Parse the array PRO%ARG in order to mimic the options mechanism provided
by a standard command.
When a procedure is executed, the array PRO%ARG is filled with the argu-
ments passed to the procedure. If you invoke the command PARSE with some
option names and required number of arguments, it will parse the argu-
ments to gather them by options and option arguments into the structure
PRO%PARSE%. The command PARSE will check that the caller has provided
known options and correct number of arguments, else an error will be
raised.
For example, if you invoke your procedure like this:
SIC> @ myprocedure 123 /MYOPTION "ABC"
the PRO%ARG array will contain
SIC_3> EXA PRO%ARG
PRO%ARG is a character*256 Array of dimensions 3
123
/MYOPTION
ABC
Invoking the command PARSE in your procedure e.g.
SIC_3> PARSE /MYOPTION /OTHEROPTION
will gather the command and the 2 option arguments like this:
SIC_3> EXA PRO%PARSE%
PRO%PARSE% ! Structure GLOBAL
PRO%PARSE%COMMAND ! Structure GLOBAL
PRO%PARSE%COMMAND%NARG = 1 ! Integer GLOBAL RO
PRO%PARSE%COMMAND%ARG is a character*256 Array of dimensions 1
PRO%PARSE%MYOPTION ! Structure GLOBAL
PRO%PARSE%MYOPTION%NARG = 1 ! Integer GLOBAL RO
PRO%PARSE%MYOPTION%ARG is a character*256 Array of dimensions 1
PRO%PARSE%OTHEROPTION ! Structure GLOBAL
PRO%PARSE%OTHEROPTION%NARG = -1 ! Integer GLOBAL RO
Namely: the command was passed 1 argument (available in the associated
ARG array), the option MYOPTION was passed 1 argument, and the option
OTHEROPTION was absent (NARG=-1). An option is present if NARG>=0.
You can control the number of required of arguments to the command and
the options. Syntax is "/OptionName [Nargmin [Nargmax]]". If Nargmax is
absent, it defaults to Nargmin. If Nargmin is absent, it means no spe-
cific constraint. For example:
SIC_3> PARSE 1 /MYOPTION 2 3 /OTHEROPTION
means that exactly 1 argument must be passed to the command (before the
options), that at least 2 and at most 3 arguments are required for /MY-
OPTION, and that there is no check for /OTHEROPTION.