User Guide > Scripting > EZscript Libraries
Was this helpful?
EZscript Libraries
An EZscript library is an artifact containing reusable functions or subroutines. You can create EZscript libraries with Script Editor and call them from maps and processes. You can also import existing script files into EZscript libraries. For details on importing artifacts, see Managing Workspaces, Projects, and Integration Artifacts.
You can store user-defined functions in your EZscript libraries to help create complex expressions. When creating user-defined functions:
The End function statement is necessary for the integration tools to recognize the end of a function.
The function name must be unique and NOT the same as any reserved words or function names (for example, Add1Part function).
Assigning a value to the function is treated exactly the same as a Return Statement. If you assign a value to the function, it immediately returns the value assigned. Because of this, you can only assign one value to a function. So instead of assigning multiple values, assign the values to a variable.
The number of parameters set in the declaration must be the number of parameters passed when calling the function. For a map to return a value, the function name should be set to the return value. For example:
Example 1
Function ThreePartNum(X,Y,Z)
If IsNull(Y) Or IsNull(Z) Then
X=0
Y=0
Z=0
End If
X = Cdbl(X)*65536*65536
Y = Cdbl(Y) * 65536
Z = Cdbl(Z)
ThreePartNum = Parse(1, str(cdbl(X + Y + Z)), ".")
End Function
While you can declare user-defined function parameters as ByVal, they are passed ByReference. Data typing is not allowed.
If you want to use a library thoughout a map or process, make sure to declare the function as Public.
Public Function myFun(var,var2)
'body goes here
End Function
Access libraries as described in Using EZscript Libraries in Processes and Using EZscript Libraries in Maps. Alternately, declare and call the library in an expression:
Include "C:\MyCodeModule.ezscriptlibrary"
The include statement is processed at compile time. The path must be a hard-coded string (it cannot be a macro reference or variable.)
Example 2: Containing a Value Assigned to a Variable
'Assign values to a variable and then return the variable
Function x()
 Dim y
 y = 1
 y = 2
 Return y
End Function
Last modified date: 08/10/2022