Was this helpful?
Dim Statement
 
Description
Use DIM to declare a variable outside any function and it is of MODULE scope.
Use DIM, to declare a variable within the function and it is of LOCAL scope.
Syntax
Dim variable [As datatype]
Remarks
The Dim statement uses the following parts:
variable - (required) Name of the variable.
As datatype - (optional) Specifies a datatype for the variable. Needed if it is anything other than Variant.
Put your Dim statements at the beginning of the procedure. You do NOT have to declare an object type if the variable is a variant, but you MUST declare object type if it is not a variant. Following are some declaration examples:
Dim qty
Dim qty As Integer
Dim myImport As DJImport
Limitation
There is no limitation of on the number of Private-level variables. In most statements, Dim declares a Private-scoped variable.
When used with a user-defined function, Dim create a function-scoped variable.
Example
This example uses the Dim statement to declare a variable in an expression, where "Result" is the variable name. The If Then Else statement is looking for Result A, else if Result A is not true, then a Null is returned:
Dim Result
Result = UCase(Left(FieldAt("/SOURCE/R1/Field1"), 1)
If Result == "A" Then
  Result = UCase(Left(FieldAt("/SOURCE/R1/Field1"), 1)
Else
  Result = ""
End If
Result
Note:  The Dim statement creates a local variable. This means that the Dim variable is local to the expression in which it is defined. So, if you create a variable using the Dim statement in one step, it is invisible to the all of the other steps in the transformation.
Last modified date: 02/01/2024