System Functions

ARG( )

Parse String Arguments

Formats

1.

Return Argument from String:

ARG(string$, argno[,delim$] [,ERR=stmtref])

2.

Replace Argument in String:

ARG(EDIT string$, argno, newval$ [,delim$] [,ERR=stmtref])

Where:

string$

String containing a series of arguments/values each separated by a single character.

argno

Number of the argument in the string to return or replace (one based).

delim$

Character that separates each of the values string$. If omitted, the system default field separator is used.

newval$

New value to insert into string$.

stmtref

Program line number or statement label to which to transfer control.

Format 1

This form of the ARG function extracts a specific field from a delimited string. If no delimiter is specified, the system uses the default SEP character (normally $8A$).

Format 2

This form of the ARG function generates and returns a new string, replacing the field specified with that supplied in <newvalue>.

If the field specified did not exist, additional delimiters will be added in the string to make up for the missing fields. If no delimiter is specified, the system uses the default SEP character.

Example

Given X$ = "a,b,c,d,e,":

ARG(X$, 1, ",")

Returns "a"

ARG(EDIT X$, 2, "Cat", ",")

Returns "a,Cat,c,d,e,"

ARG(EDIT X$, 7, "Dog", ",")

Returns "a,b,c,d,e,,Dog,"

(The substring parsing capabilities of the ARG function were added in PxPlus v7.00.)