Array.Decode |
Top Previous Next |
Searches the given array for an expression and returns the element after it.
Syntax function Array.Decode(Expression: variant; ASearchArray: array): variant function Array.Decode(Expression: variant; ASearchArray: array; ADefault: variant): variant
Alternative Names
Description The array should contain an even number of items of ID, VALUE pairs. This routine tries to match the given expression against the ID element of each pair and returns the corresponding value. If the expression cannot be matched, the routine returns NULL or the given default.
Expression is the ID value to look up in the array.
ASearchArray holds a previously created array with ID, VALUE pairs as the elements.
The Return Value is the value element of a found ID, VALUE pair, NULL or the supplied default if no matching ID can be found.
Example execute UDSBlock returns (result_value varchar(100)) as begin /* create an array with 3 id=value pairs */ a = Array.Create(1, 'first', 2, 'second', 3, 'third');
result_value = Array.Decode(1, a); suspend; /* returns 'first' */
result_value = Array.Decode(2, a, 'not found'); suspend; /* returns 'second' */
result_value = Array.Decode(4, a); suspend; /* returns NULL */
result_value = Array.Decode(4, a, 'not found'); suspend; /* returns 'not found' */ end |