Was this helpful?
Reusable Scripts
Script libraries are independent artifacts that contain any script and can be referenced by multiple maps or processes. When you use the same (or similar) script in more than one map or process, you must consider using a Script Library. For information about Script Libraries, see EZscript Libraries.
User Defined Functions (UDF) allow lengthy scripts to be condensed into a single function call. Any time the script has to be used more than once within a map or a process, you must consider creating a UDF. Again, the change-once, use many times principle applies. For more information about UDFs, see Function Statement.
Declare and define the function:
' Call this function to ensure properly formatted zip codes (USA)
Public Function validZip(zipcode)
If len(trim(zipcode)) <> 0 then
if trim(zipcode) ~ "^([0-9]{5})([\-]{1}[0-9]{4})?$" then
return true
else
return false
end if
else
return false
end if
End Function
Also, experienced users can create and maintain more complex scripts and new users can easily use it in the form of function calls. In the zip code validation example, anyone building a new map can take advantage of the rule by calling it from a map or process.
Call the function:
validZip(FieldAt("/SOURCE_1/R1/Zip"))
Last modified date: 08/02/2023