Propeller Manual

Table Of Contents
2: Spin Language Reference – OBJ
OBJ
Designator: Declare an Object Block.
OBJ
Symbol [Count]: "ObjectName" Symbol [Count]: "ObjectName"
Symbol is the desired name for the object symbol.
Count is an optional expression, enclosed in brackets, that indicates this is an array of
objects, with Count number of elements. When later referencing these elements, they
begin with element 0 and end with element Count-1.
ObjectName is the filename, without extension, of the desired object. Upon compile,
an object with this filename is searched for in the editor tabs, the working directory
and the library directory. The object name can contain any valid filename characters;
disallowed characters are \, /, :, *, ?, ", <, >, and |.
Explanation
The Object Block is a section of source code that declares which objects are used and the
object symbols that represent them. This is one of six special declarations (
CON, VAR, OBJ, PUB,
PRI, and DAT) that provide inherent structure to the Spin language.
Object declarations begin with
OBJ on a line by itself followed by one or more declarations.
OBJ must start in column 1 (the leftmost column) of the line it is on and we recommend the
lines following be indented by at least one space. For example:
OBJ
Num : "Numbers"
Term : "TV_Terminal"
This example defines Num as an object symbol of type "Numbers" and Term as an object
symbol of type
"TV_Terminal". Public and Private methods can then refer to these objects
using the object symbols as in the following example.
PUB Print | S
S := Num.ToStr(LongVal, Num#DEC)
Term.Str(@S)
This public method, Print, calls the Numbers ToStr method and also the TV_Terminal’s Str
method. It does this by using the
Num and Term object symbols followed by the Object-
Propeller Manual v1.1 · Page 141