ALD Objects > Variables
  
Variables
Conditional formatting is one of the cornerstones of the PTC ALD document production process and, by association, the capture, store and output of contextual information is its most important step. PTC ALD variables provide this function. They are named areas of memory containing strings, numbers or arrays composed of either PTC ALD environment information or user-modified values. Once the variable information has been set, values can be extracted using tests, usually as part of an PTC ALD script or via a showstring, and passed to document formatting processes to provide the conditional data they require. See Tests for further information about tests.
Global Variables
Global variables hold the second type of data described in the paragraph above; that is, they are assigned values and modified by the user via PTC ALD's system of macros, scripts and showstrings. They are defined by the user, stored within the PTC ALD application itself and can be shared amongst any number of open documents or tags during one session. Their values are usually reset to their default when the PTC ALD session is terminated. It is, however, possible to save an external snapshot of current values at any time by passing the savevars macro. This set of values can then be reinstated when it is needed.
The syntax of a global variable is its name preceded by the ^ character. A list of suggested global variable syntaxes is included in the reference chapter document Variables, included in the Help for your PTC ALD product. Full descriptions are, however, out of scope of this document.
Getvars
PTC ALD getvars store environment information, generated by PTC ALD and current at any one time of request:
System information, e.g. date and time, currently selected printer, etc.
Document details, e.g. page number, position in text stream , etc.
Formatting properties, e.g. current column width, last word on page, etc.
Every getvar is made up of a specific code, which identifies the type of information it contains. A full list of getvar codes can be found by running the wmnx 800 macro or selecting the Text > Show string > Insert showstring > 3b2 variable (getvar) > menu option to invoke the category list shown below. Hover over each of the categories in turn to view a full list of the codes it contains.
The value of a getvar is extracted by running the getvar macro followed by the relevant code for the information you require. The resulting value is then often passed to a global variable for use during conditional formatting. For example, the code phrase getvar 21522,"cursor_pos" will extract the current cursor position in the text stream and feed this information into a variable called "cursor_pos". The global variable can then be queried to specify that particular formatting should only be applied when the cursor is in a certain position in the text stream. It is also possible to query getvars in this way. This ability to query global and getvar variable information is unique to PTC ALD and consolidates its ability to format any piece of data, anywhere in a document and at any time.
 
It is useful to note here that getvar values are made up of PTC ALD's own internal system information, made available to users. The values may not always be that which the user expects. For example, the formatting process may changes values of variables such as baseline position, which in turn may affect the positioning of objects if this baseline information is being relied upon during document build.
Counters
Counters are small memory slots controlled by the user to provide contextual information about the contents of a particular stream, for example to state that a paragraph is the second one after a page heading. They are applicable only to the stream in which they are set.
There are two types of counter:
1. Counters: hold number information
2. String counters: hold text
As with getvars, the value of a counter can be passed to a global variable to contribute to the contextual nature of the document formatting process.
In contrast to getvars, however, counters are "format friendly"; that is, they follow the flow of the content stream rather than hold global information for a document.