;
After the word ?var? is a space followed by the name you would like
to use for the variable. After the name (no space required) is a colon,
and after the colon (no space required) is the variable type followed
by a semicolon (which means ?end of statement?). Example variable
declarations include:
var MoveDistance:longint;
var FirstTimeThroughProcedure:boolean;
var TorqueValue:integer;
var UserMessage:string;
Variable names must not have any spaces (although an underscore
character may be used) and in general should only be composed of
letter and numbers. Variable names may include numbers but may
not begin with numbers.
Aggregate Types
Consider a ?desk organizer? in aesk drawer. A desk organizer contains various compartments for holding different types of
things commonly found in a drawer such as paper clips, pencils etc.
The desk organizer is a single, integrated item that has internal
structure of various compartments, each compartment providing a
suitable place for a particular aspect of its storage purpose. In a similar manner most high level programming languages allow the con-
struction of such informational ?desk organizers?, data structures that
contain ?compartments? where information can be stored while
retaining a relationship with the whole. The language supports
aggregate structures through Record and Object type declarations.
The creation of new Record and Object structures will be deferred
until the Advanced Language section however the use of predefined
record and object types will be reviewed here. Predefined aggregate
types include examples such as:
T1Axis.............single axis of motion
T2Axis.............2 coordinated axis of motion
T3Axis.............3 coordinated axis of motion
T4Axis.............4 coordinated axis of motion
T5Axis.............5 coordinated axis of motion
T6Axis.............6 coordinated axis of motion
TButton............Windows Button Control (Snap2Motion only)
TEdit..............Windows Edit Control (Snap2Motion only)
TFile..............PC File (Snap2Motion only)
TListBox...........List/Combo box control (Snap2Motion only)
TPlate.............Assembly "Base" for applications
TPrompter..........Modal dialog for operator (Snap2Motion only)
TStatic............Output text/display (Snap2Motion only)
The first group are different types of coordinated axis groups and are collectively
referred to as TNAxis. In actual usage the ?N? in TNAxis
replaced with a number between 2 and 6 representing the dimension
of the group.
A ?compartment? or ?field? of an object or record is indicated with a
period after the variable name followed by the field name. The
period indicates that the name following is specifically related to that
variable. Field names can indicate component storage areas in an
aggregate variable such as a record or object. Records contain only storage areas. Objects contain storage areas
just like records and as well type specific procedures and functions
which can operate on that information.
Objects and records are declared with the VAR keyword. A variable to represent a 2 axis positioning
table could be declared with the command:
var PositioningTable:T2Axis;
This new variable named PositioningTable can be
given commands. The first command necessary is an initialization
command to associate that variable with actual axis in the system, for
example:
PositioningTable.Init(XAxis,YAxis);
XAxis and YAxis are predefined variables of type T1Axis which
correspond to the physical X and Y axis in the control system. Now the
PositioningTable can be given a command to move, for example:
PositioningTable.SetMotor(On);
PositioningTable.MoveBy(20000,30000);
Detailed information about the predefined variables and operations can be found in the
Command Reference.
The remaining types shown are for use specifically with Snap2Motion. Some of these types are declared graphically
while others are declared with the ?var? keyword. In general these
other types provide Windows components that can be manipulated
by the application program to display information and product actions.
Arrays
Up until this point variables have been named symbolically and their
access has been explicit on the part of the programmer. Arrays are a
tool that give the program itself the ability to specify what storage
area will be used to save information.
Arrays are linear arrangements of variables of a particular type. When
referring to information in an array the name of the array is indicated
as well as an index indicating which element is being used, for example the first one, or the third one. The location of the
storage area of interest can be expressed numerically giving the
program the ability to indicate a desired location.
Arrays may be specified in Snap2Motion as plate variables through a dialog
box such as shown below:
Any variable has the capacity to be part of an array. When defining a
variable you can check the box indicating the variable represents an
array and indicate the array bounds. The language allows the lower
bounds and upper bounds of an array to be chosen. Note that the bounds may be
symbolic constants.
Arrays of longints are frequently used as ?storage scope buffers? to
collect position or information at the controller sample rate to
be later plotted showing step response results or other information.
To create a variable array explicitly start with the VAR keyword and follow it
with the name of the array. Following the name place a colon. Following the colon place
the keyword array followed by a left square bracket, the lower
bound either as a number of constant, two periods, the upper bound
as a number of constant, a right square bracket, the word of and
then the type of the array?s components followed by a semicolon. An
example of an array declaration might be:
var DataBuffer:array[1..DataBufferSize] of longint;