 Parse instruction parse term template; where template is one or more non-numeric symbols separated by blanks and/or patterns, and a pattern is one of: literalstring [indicator]number [indicator](symbol) and indicator is one of +, -, or =. The parse instruction is used to assign characters (from a string) to one or more variables according to the rules and templates described in the section Parsing templates. The value of the term is expected to be a string; if it is not a string, it will be converted to a string. Any variables used in the template are named by non-numeric symbols (that is, they cannot be an array reference or other term); they refer to a variable or property in the current class. Any values that are used in patterns during the parse are converted to strings before use. Any variables set by the parse instruction must have a known string type, or are given the NetRexx string type, Rexx, if they are new. The term itself is not changed unless it is a variable which also appears in the template and whose value is changed by being in the template. Example: parse wordlist word1 wordlist In this idiomatic example, the first word is removed from wordlist and is assigned to the variable word1, and the remainder is assigned back to wordlist. Notes: - The special words ask, source, and version, as described in the section Special names and methods, allow:
parse ask x -- parses a line from input stream parse source x -- parses 'Java method filename' parse version x -- parses 'NetRexx version date' These special words may also be used within expressions. - Similarly, it is recommended that the initial (main) method in a stand-alone application place the command string passed to it in a variable called arg.[1]
If this is done, the instruction: parse arg template will work, in a stand-alone application, in the same way as in Rexx (even though arg is not a keyword in this case).[2]
|