Propeller Manual

Table Of Contents
VAR – Spin Language Reference
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.
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.
Variable Declarations (Syntax 1)
The most common form of variable declarations begins with
VAR on a line by itself followed
by one or more declarations.
VAR must start in column 1 (the leftmost column) of the line it is
on and the lines following it must be indented by at least one space.
VAR
byte Str[10]
word Code
long LargeNumber
This example defines Str as a byte array of 10 elements, Code as a word (two bytes) and
LargeNumber as a long (four bytes). Public and Private methods in the same object can refer
to these variables in ways similar to the following:
Page 210 · Propeller Manual v1.1