Developer Documentation Library > Scripting > mrScriptBasic overview > mrScriptBasic language reference > General information > User-defined constants
 
User-defined constants
You can define user-defined constants in mrScriptBasic using the Const statement. Using the Const statement, you can create string, numeric, or categorical constants with meaningful names and assign them literal values. For example:
Const COMPANY_NAME = "UNICOM"
Const MISSING = -99
Const WHITE_WINES = {Chardonnay, Riesling, SavBlanc}
The string literal is enclosed in "" (quotation marks) and categorical literals are enclosed in {} (braces). A categorical constant is not part of the metadata. It is just a convenient way to create a list of categories that can be used in expressions. For example:
If WinesTasted.ContainsAny(WHITE_WINES) Then
' Ask questions relating to white wines
...
End If
You can define user-defined constants in the main script block or in any Function or Sub procedures accessed by the script block. By default, user-defined constants in the main script block are not visible to Function and Sub procedures, but you can make them visible by including an Option GlobalVariables statement in your script. Note that this option will also make any Variables in the main script block visible to Functions and Sub procedures.
See also
Script constants
mrScriptBasic language reference
General information