Variables and constants
- Definitions
Variables are an essential to any programming language. A variable is an identifier (a name) for a storage location (part of the computers memory) which holds a value of some sort. This just means that you can use the name of the variable to reference a value in the computers memory, and you can use the same name to change the value of the variable. Constants are just variables that cannot be changed. - Data Types, declarations and scope
We have already seen that a variable is a name, that contains a reference to a value. In the above example we also saw that this value does not have to be a number, it could also be some text. This means that the variables have different data types. - Array declaration
Arrays are declared in a similar way to variables. You use the Private, Public, Dim or Static keywords and use integer values to specify the upper and lower bounds for the array. You use the As keyword to declare the array type. - Object variables
Variables with an object data type have their values assigned in a little different way, and they deserve special attention. Object variables are variables containing a reference to a certain object. This could be a project, a translation list etc. The object variable would have the same properties and methods as the object itself, and changing the variable affects the object. To assign an object to an object variable you need to use the Set statement. The following example illustrates the use of object variables. They are also used elsewhere in this document. - Built-In constants
You are allowed to declare constants yourself as mentioned above, but Passolo and Sax Basic also have a wide range of built-in constants. The purpose of these constants is the same as of the constants you declare yourself. They can be used to make the code easier to read, and they allow certain values to be changed, and the code would still work.