Previous Topic Next topic Print topic


&PARSE

Parses a Customizer text string. &PARSE facilitates the following tasks.
Restriction: This topic applies only when the AppMaster Builder AddPack has been installed, and applies only to Windows platforms.
  • Parsing rule arguments or parameter strings that have embedded punctuation, operators, or keywords. You can split the string into two strings--the part preceding and the part following the first occurrence of the operator string. Then, you can skip past embedded single- or double-quoted strings when looking for the first occurrence of the operator string.
  • Eliminating the trailing and leading spaces from both of the new strings, making them easier to read.
  • Parsing long parameter strings by loops. You can reload the string that follows the operator string into the original string variable.

Syntax:

&PARSE( &string[value])

Aliases:

&parse( &string[value])     &Parse( &string[value])

Parameters:

&String Variable with a string value.
Value Can be:
  • A literal text string.
  • A variable with a string value.
  • A number (the number turns into a string).

Comments:

  • Value is matched against the string value of &string. The part of the &string value following the match is stored back in &string, with leading and trailing spaces eliminated. Then, the part of the &string value preceding the match returns as the value of the parsing function, with leading and trailing spaces eliminated.
  • When matching the second string inside the first string, the match does not begin within a string that is embedded (quoted) within the first string.
  • When using &PARSE with only one argument, the argument must be a variable with a string value. The string in the argument is assigned the null string and the original string is returned as the value of the parsing function with leading and trailing spaces trimmed.

Examples:

If &STR is assigned by the statement % &STR = " X, PARM = `A, B', Y", then

This statement... Is equivalent to...
% PART = &PARSE( &STR, ",") % &STR = "PARM = `A, B', Y"

% &PART = "X"

If &PARSE is used again on &STR:

This statement... Is equivalent to...
% &PART = &PARSE( &STR, ",") % &STR = "Y"

% &PART = "PARM = `A, B'"

Note that the comma embedded in `A, B' is ignored.

If &PARSE is used again on &STR:

This statement... Is equivalent to...
% &PART = &PARSE( &STR, ",") % &STR = ""

% &PART = "Y"

And finally, if &PARSE is used again on &STR:

This statement... Is equivalent to...
% &PART = &PARSE( &STR, ",") % &STR = ""

% &PART = ""

In other words, after processing, you get the following result.

% &PART = &PARSE( &STR, ",")

Where

  • &PART contains what was in the value of &STR up to but not including the first comma (with leading and trailing spaces trimmed).
  • &STR contains what was in the value of &STR, after and not including the first comma (with leading and trailing spaces trimmed).

IF &STR is assigned by the statement % &STR = " ABC ":

This statement... Is equivalent to...
% &PART = &PARSE( &STR) % &STR = ""

% &PART = "ABC"

Because the argument is restored before the &PARSE value is passed, &PARSE eliminates spaces and returns the string to the original variable.

If % &STR = " ABC ":

This statement... Is equivalent to...
% &STR = &PARSE( &STR) % &STR = "ABC"
Previous Topic Next topic Print topic