You are here: Grammar and Syntax > Assignment Statements > Creating and Assigning Variables

Creating and Assigning DAL Variables

DAL automatically creates a variable if the first time you use it is to assign it a variable, for example:

MyVar = "This text string."

If the variable MyVar did not exist, then it would automatically be created and assigned the given value. If you use a DAL variable in any other statement before creating a runtime syntax, this causes an error.

When you have routines that would usually expect a DAL variable to have been previously declared before reaching this code, you may include a statement such as:

MyVar = MyVar

This will create the variable if it did not exist, but it does not change the value of the DAL variable if it was previously declared and assigned a value.

You can also use the DECLARE function to ensure that a variable exists without assigning it a value. That is, instead of using:

MyVar = MyVar

you can use:

Declare("MyVar")

If you do not specify the code page parameter, then the existing string variable does not change. New variable declarations use the default code page if you omit the parameter.

See Also