User Guide > Scripting > Script Statements > Option Runtime Statements
Was this helpful?
Option Runtime Statements
Option runtime statements specify how the map performs compilation or runtime operations. These statements are transformation-level settings; once used, the statement remains in effect throughout all expressions in a transformation, unless another statement changes the setting.
The available option runtime statements include:
Option Evaluate Automatic Statement
 
Description
Execute a target field expression and determines its value (default behavior)
Syntax
Option Evaluate Automatic
Remarks
Option Evaluate Automatic is the default behavior, but if you use the Option Evaluate Manual statement and then want to return to default behavior, you must include the Option Evaluate Automatic statement.
Example
The Option Evaluate statements work in ANY expression, be it filter expressions or field expressions. They may also be used multiple times within the same expression:
Option Evaluate Manual
old_val = Targets(0).fields("Field1")
Option Evaluate Automatic
new_val = Targets(0).fields("Field1")
printf("The old value is " & old_val & ", the new value is " & new_val)
Option Evaluate Manual Statement
 
Description
Evaluate the value within a target field memory buffer
Syntax
Option Evaluate Manual
Remarks
If you reference a target field name in an expression, by default, a map will execute the target field expression for that field to determine the value. When Option Evaluate Manual is used, the target field expression is not executed. A map instead references the last value evaluated in the memory buffer for that target field. This is especially useful when manually mapping (using a variable in Event actions to map your target data).
Example
The Option Evaluate statements work in ANY expression, be it filter expressions or field expressions. They may also be used multiple times within the same expression:
Option Evaluate Manual
old_val = Targets(0).fields("Field1")
Option Evaluate Automatic
new_val = Targets(0).fields("Field1")
printf("The old value is " & old_val & ", the new value is " & new_val)
Note:  Option Evaluate Automatic is the default behavior. If you use Option Evaluate Manual and you want to return to default behavior, you must include the Option Evaluate Automatic statement.
Option Explicit Statement
 
Description
Requires that variables be declared before they are first used.
Syntax
Option Explicit
Remarks
When Option Explicit On or Option Explicit appears in a file, you must explicitly declare all variables by using the Dim, Public, or Private statement. It is usually (but not necessarily) the first statement in an expression, so it is used more as a policy setting rather than a property that is turned on and off. The default is Option Implicit.
The Option Implicit statement, which does not require that variables be declared before they are first used, is the default behavior, but this can be changed in the cosmos.ini file.
Option Explicit applies to the entire "expression context", excluding Process steps and Transformation steps. Every transformation or process step, uses the public context (scope) of the parent process, and also has its own private context (scope).
The Explicit/Implicit setting is stored in the private-scope of an expression context (that is the entire transformation or process step). Target mapping expressions and BeforeTransformation event expressions, both use the same context, so you don’t need to re-declare Option Explicit or Implicit.
Example
This statement, which includes Option Explicit, generates an error at run time, since the declared variable name is misspelled. If the Option Explicit function is not used, the error is simply written as an error message in the log. The compiler does not error out, since it automatically defines the misspelled variable name for you. It is, therefore, useful to always use Option Explicit when declaring variable names in a transformation.
Option Explicit
Dim srvr_name
srvr_name$ = "NTServer"
Print ("Using server " & svr_name)
'^^^^^^^
'undefined variable name
Best Practice — Declare Option Explicit statements at the beginning of your script and then call the script file in the expression. This file may then be shared between modules in multiple transformations. It is more efficient to declare Private variables once in a script file, rather than declaring them in each transformation script.
Option FieldExplicit Statement
 
Description
Causes the script to fail with a runtime error if referencing a field (or record) that does not exist.
Syntax
Option FieldExplicit
Remarks
This can be set in the BeforeTransformation event, and applies to all code modules. If it is to be used in a single code module, it is usually the very first statement in that module.
When writing user-defined functions, Option FieldExplicit is the default behavior.
To treat missing elements as Nulls, use the Option FieldImplicit Statement.
Option FieldImplicit Statement
 
Description
Cause a null value is pushed on the stack rather than a field (or record) reference if referencing a field (or record) that does not exist.
Syntax
Option FieldImplicit
Remarks
This can be set in the BeforeTransformation event, and applies to all code modules. If it is to be used in a single code module, it is usually the very first statement in that module. When writing user-defined functions, Option FieldExplicit Statement is the default behavior.
Option Implicit Statement
 
Description
Turn off the requirement that variables be declared before they are first used
Syntax
Option Implicit
Remarks
This is usually the very first statement in a code module, so it is used more as a policy setting rather than a property that gets turned on and off.
When writing user-defined functions, keep in mind that Option Implicit is the default behavior, but this can be changed in the cosmos.ini file. Use of Option Implicit is generally not a good practice. The Option Explicit statement, is recommended, since Option Explicit requires that variables be declared before they are used.
Example
This program simply results in a bug in the code. The interpreter does not complain, since it would just automatically define the misspelled variable name for you.
Option Implicit
Dim srvr_name
srvr_name$ = "NTServer"
Print ("Using server " & svr_name)
                        '^^^^^^^
                        'undefined variable name
Option Math Fast Statement
 
Description
If both operands are longs, the map performs long (32-bit integer) arithmetic. If either operand is a floating point number, the arithmetic is performed as floating point.
Syntax
Option Math Fast
Remarks
Math is performed using floating point values, since they are much faster than decimal values unless one of the operands is a decimal.
This statement is a context-setting at the transformation level. If Option Math Fast is used once, the setting remains in effect for all expressions in a transformation, unless another statement changes the setting.
Option Math Precise Statement
 
Description
Perform decimal arithmetic
Syntax
Option Math Precise
Remarks
Setting this causes number constant values to be treated as decimal (that is, “&D” is not needed as a prefix to specify that the number should be treated as a decimal number).
Thus this statement is used to force decimal arithmetic, unless one of the operands is a floating point number and the the other operand is not a decimal. In this case, the math is done as floating point. If the result overflows or underflows, it converts both numbers to floating point and tries again.
This statement is a context-setting at the transformation level. If Option Math Precise is used once, the setting remains in effect for all expressions in a transformation, unless another statement changes the setting.
Option Math Strict Statement
 
Description
Perform decimal arithmetic
Syntax
Option Math Strict
Remarks
This statement is similar to Option Math Precise Statement, however, if an overflow or underflow occurs, a run-time error is generated (instead of transformation of the numbers to floating point).
This statement is a context-setting at the transformation level. If Option Math Strict is used once, the setting remains in effect for all expressions in a transformation, unless another statement changes the setting.
Last modified date: 12/03/2024