VAR

Designator: Declare a Variable Block.

VAR
  Size Symbol < [Count ] > < Size Symbol < [Count ] >>...


VAR
  Size Symbol < [Count ] > < , Symbol < [Count ] >>...

  • Size is the desired size of the variable, BYTE, WORD or LONG.
  • Symbol is the desired name for the variable, and must be unique to the object.
  • Count is an optional expression, enclosed in brackets, that indicates this is an array variable, with Count number of elements; each being of size byte, word or long. When later referencing these elements, they begin with element 0 and end with element Count-1.

Explanation

VAR is the Variable Block declaration. The Variable Block is a section of source code that declares global variable symbols. This is one of six special declarations (CON, VAR, OBJ, PUB, PRI, and DAT) that provide inherent structure to the Spin language.

In Spin, all variables defined in VAR blocks are initialized to zero. Though it is rarely implemented, it is possible to force these variables to initialize to a non-zero value upon the next boot up by including code that updates the application's global variable area in the external EEPROM.

See Variables for more information on variables in Spin.

Unless otherwise noted, content on this site is licensed under the
Creative Commons Attribution-ShareAlike 4.0 International License.