The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information....



ExtractParam


Unit:SDL_stringl
Class: none
Declaration: function ExtractParam (ParamId: string; StartPos: integer; AssignChar, Terminator: char; InString: string): string;

The function ExtractParam extracts and returns a parameter from the string InString, starting the extraction process at the string position StartPos. The constant identifier ParamId contains the name of the parameter to be extracted (case insensitive). The parameters AssignChar and Terminator define the assignment and the terminating characters, respectively.

If the parameter defined by ParamId cannot be found in the string InString an empty string is returned, otherwise the value of the parameter is returned.

Hint: The terminator may be omitted at the end of the input string

Example 1: Assuming InString to contain the following string:
MyTest (P1=1000; P2=3310)
the expression
astr := ExtractParam ('P1', 1, '=', ';', InString);
extracts the value of P1 (the string '1000') and assigns it to the string astr.

The expression

astr := ExtractParam ('P2', 1, '=', ';', InString);
extracts the value of P2 as '3310)' (the closing parenthesis is included because of the missing terminator).

Example 2: If the Terminator is part of a parameter definition, the parameter value has to be enclosed in double quotes. The following example should clarify this:

Assuming InString to contain the following string:

MyParam="This : is a colon":SecondPar=2000
the expression
astr := ExtractParam ('MyParam', 1, '=', ':', InString);
extracts the value of MyParam as 'This : is a colon'. Without quotes the extracted string would be 'This '.



Last Update: 2023-Feb-06