Null
Within Digitise Apps Scripts Null generally represents the absence of a value. For example, if you write a = Null within a Script, it means that the variable a is cleared of any existing value.
As a result, the use of the word Null within Scripts is restricted and is what is called a reserved word, which means that you can't use it for variable or function names. The reservation is case-insensitive and includes NULL, NuLL, null etc.
The word allows you to:
-
Assign Null values to data items and variables.
-
Check for Null values in comparison statements.
-
Obtain a Null value from the Scripting Methods GetCurrentRecordValue or GetRecordValue.
-
Pass Null values to the Scripting Methods SetCurrentRecordValue and SetRecordValue.
-
Specify no Data Sources to be uploaded or downloaded in the Synchronise Scripting Method.
-
Pass Null values to user-defined Functions.
The Scripting Method, IsNull, allows you to check for Null values.
In Digitise Apps' predecessor MX, apps created with a version of MX prior to v10, could use Null as a variable or function name because Null was not a reserved word. To provide backwards compatibility for these apps when upgrading to Digitise Apps, the Project Properties include a Property Enable Null Script Variables which allows you to choose between using Null as a reserved word or not.
If Enable Null Script Variables is set to True, Null behaves as a reserved word and signifies a Null value and cannot be used as a variable or function name. This is the default value for new Projects or Projects created with MX v10 onwards.
If Enable Null Script Variables is set to False, Null is NOT a reserved word and can be used as a variable or function name. App Studio will automatically set this as the default value for apps created with a version of MX prior to v10 when upgrading to the latest version of Digitise Apps.
Note that calling:
MsgBox(GetCurrentRecordValue(datasource, field))
where GetCurrentRecordValue returns a Null, will display an error message.
Using a variable to store the return value and then passing the variable to the MsgBox call instead may prevent the error message from appearing and display an empty message box instead:
Dim strFieldVal = GetCurrentRecordValue(datasource, field)
MsgBox(strFieldVal)