Tip handling void values in function parameters and return values
In the Sage X3 language, there is no dedicated keyword for null numeric, dates, or string values. The only exception is the Null pointer.
Technically, an empty string, a null date, or a zero numeric value can be declared with the following syntaxes:
# Assigning "null" values
MY_DATE=[0/0/0]
MY_DECIMAL=0
MY_STRING=""
# Another solution
Raz MY_DATE, MY_DECIMAL, MY_STRING
Even if the behavior is the same, it can be important to identify new values when assignments are done. For this purpose, a dedicated AVOID instance exists now with a property per type: ACHAR, AINT, ADATE, ACLOB, ADEC, and so forth.
Using these "null constants" makes the code easier to read:
# Assigning "null" values
MY_DATE=AVOID.ADATE
MY_DECIMAL=AVOID.ADEC
MY_STRING=AVOID.ACHAR
There is also another important feature: assigning a
AVOID
value to a property is allowed while keeping the property value unchanged. This is especially useful when a method or a function requires a parameter (sent as a variable) that you do not want to manage. In that case, AVOID
will prevent you from declaring a variable that will not be used. The same concept applies for other return values that have to be ignored. For example:AVOID.AINT=Fmet this.METHOD : # I do not care about the return value
Call MYROUTINE(PARAM1, PARAM2, AVOID.ACLOB) : # The last parameter is a clob that can be empty
This good practice can be summarized as follows:
When dealing with null values, don't avoid 'AVOID'!