ExpandParm Method
The ExpandParm method returns a string object that is obtained from the target string object by expanding substitutable parameters in the text. These parameters follow the syntax defined for query SQLSelect parameters as documented in the Programming Guide.
This method has the following syntax:
StringObject = StringObject.ExpandParm(scope = Scope)
This method has the following parameter:
scope
Specifies the scope used to evaluate the variable or expression
Anywhere, except with the following exceptions, when a target string contains a colon (:) or ampersand (&) followed by a valid variable name or parentheses-enclosed 4GL expression, the colon or ampersand together with the variable name or expression is replaced by the current value of the specified variable or expression in the scope that was provided.
If the 4GL expression or variable being evaluated is to be followed by any character such as a period (.), which has special meaning within 4GL variables and expressions, the variable or expression must be enclosed within parentheses if the trailing special character is to be interpreted literally. Otherwise the special character will be interpreted as being part of the variable or expression to be evaluated.
The following 4GL code in a frame named Example, illustrates the literal substitution attempt of the period (.) character:
initialize() =
declare
strobj = StringObject;
dog = varchar(24);
enddeclare
{
dog = 'poodle';
/*
** After the following two statements, strobj contains the value:
**
** 'The quick brown fox jumped over the lazy poodle.'
*/
strobj.Value = 'The quick brown fox jumped over the lazy &(dog).';
strobj = strobj.ExpandParm(scope = Curframe.Scope);
/*
** But after execution of the next two statements, the strobj
** reference is unexpectedly NULL because the last statement
** causes runtime errors:
**
** E_WT0029 Error at line 28 of Example.
**
** E_W400F0 Syntax error. The last symbol read was ';'.
*/
strobj.Value = 'The quick brown fox jumped over the lazy &dog.';
strobj = strobj.ExpandParm(scope = Curframe.Scope);
}
Within single or double quotes, this expansion is done only for ampersands, not colons. A pair of ampersands is replaced by a single ampersand, without any expansion. A colon is always interpreted as part of a substitution, never as an ordinary character. For more information about how this method expands parameters, see the SQLSelect
Query attribute (see
Query Attribute).
If there are errors (such as a variable name not being defined in the specified scope), the method returns null.