beautypg.com

Dictionary objects, Procedure objects – AMT Datasouth PAL User Manual

Page 23

background image

Objects

17

3.2.2.

Dictionary Objects

The programmer creates dictionary objects in the exact same manner as arrays. Except, dictionary
objects use the "<<" and ">>" operators. The "<<" operator serves the exact same purpose as the
"[" operator and mark predefined name. When PAL encounters the "<<" operator, PAL simply
pushes a mark object onto the stack.

Later, when PAL encounters the ">>" operator, PAL builds a dictionary object from all the objects
on the stack above the top-most mark object. Between the "<<" and ">>" operators, the
programmer may perform any combination of operations necessary to place the desired dictionary
data onto the stack.

PAL organizes the entries within a dictionary into pairs. PAL treats the first object of each pair as a
key, and the second object as the value associated with the key. Therefore, the programmer must
always specify an even number of objects when creating an array.

When pushing dictionary objects onto the operand stack when creating a dictionary, the pro-
grammer must first push the key object of each pair followed by the value object. Therefore, a
dictionary has the following general appearance.

<<

key0 value0 key1 value1 key2 value2 key3 value3 ... keyN-1 valueN-1

>>

Dictionaries allow the programmer to access a particular value object by specifying the key object
associated with the value. This provides a very powerful mechanism for organizing data.

Like array objects, PAL allows dictionary objects to contain any arbitrary combination of object
types. Although PAL allows key objects of any type, PAL can search a dictionary for numeric and
name key objects more effeciently than any other type of object. Therefore, the programmer should
seriously consider using only numeric or name objects as key entries within a dictionary.

In order to take advantage of the more efficient name object searching, PAL automatically
converts string objects specified as keys to name objects. PAL does not convert string objects
specified as value entries within a dictionary. As a result, the following two dictionary definitions
result in exactly the same dictionary within the printer's memory.

<<123 (1stValue) /2ndKey /2ndData 45.76 /3rdData (4thKey) 95.11>>
<<123 (1stValue) /2ndKey /2ndData 45.76 /3rdData /4thKey 95.11>>

The following table shows the organization of this dictionary within the printer's memory.

Key

Value

123

(1stValue)

/2ndKey

/2ndData

45.76

/3rdData

/4thKey

95.11

3.2.3.

Procedure Objects

Procedure objects contain a series of objects which the programmer can instruct PAL to execute at
a future time. PAL provides the "{" and "}" operators for defining procedures. These operators do
not work like the "[," "]," "<<," and ">>" operators. Instead, the "{" operator instructs PAL to
begin recording the following PAL operations and objects into a procedure object. The "}"
operator instructs PAL to stop recording.