lrc_variant_scode
| Assignment to Variants |
Assigns a string to an error code value in a variant.
VARIANT lrc_variant_scode( const char* errcode );
VARIANT lrc_variant_scode_by_variant( const char* errcode );
| errcode | A character string representing an error code value. |
The lrc_variant_scode function converts a string containing a system error code value to an error code stored in a variant.
Be careful not to use lrc_variant_scode to create a variant of any type other than an scode error variant. For example, to create a variant to pass a long value to a function that takes a variant argument, use lrc_variant_long.
You create dynamic values for errcode in one of two ways. Either use the standard parameterization methods, or generate a string variable with the value you want to store in an scode variant. The example shows how to do this.
You can also pass a string literal:
VARIANT var = lrc_variant_scode("-2147352572");
The additional function lrc_variant_scode_by_variant is used when a variant to the variant of a system error is required.
The lrc_variant_scode_by_variant function converts a string containing a system error code value to an error code and returns a variant containing a reference to the variant containing the value.
Return Values
Parameterization
All arguments can be parameterized using standard parameterization.
Example
This example shows two ways of creating an scode variant with dynamic data.
VARIANT var ;
char varVal[80];
char errVal[15];
int i;
/* To use a variable in the call to lrc_variant_scode:
Get an error code string however appropriate for your test */
my_get_error_code_function(errval );
lr_output_message("err val = %s", errval );
//Action.c(11): err val = -9876543
// Pass the string variable as the function argument
var = lrc_variant_scode(errval );
lrc_print_variant(var);
// Action.c(15): Variant of type: scode ,with value: -9876543
/* To use parameterization in the call to lrc_variant_scode:
Use standard parameter semantics. Either define
the parameter in the script, or retrieve it from input. */
for (i = 0; i<4; i++) {
/* The parameter errcode is defined in the script with values:
-2147352572
-200000000
-300000000
-400000000 */
var = lrc_variant_scode("<errcode>");
lrc_print_variant(var);
lr_advance_param("errcode");
}
Example: Output:
Action.c(31): Variant of type: scode ,with value: -2147352572
Action.c(31): Variant of type: scode ,with value: -200000000
Action.c(31): Variant of type: scode ,with value: -300000000
Action.c(31): Variant of type: scode ,with value: -400000000

