Arrays are useful in one-pass posting as a tool to save information on a per-channel or per-tool post basis in a compact and organized way.
One example of the use of arrays in one-pass posting is to allow for modality. The way the posting order is used in multi-pass posting causes problems with modality, so values must be saved off and loaded in arrays to preserve the information. ModalityLoad and ModalitySave are the conventional custom formats where this takes place.
ModalityLoad may contain lines such as the following:
[:<$COOLANT-ON-1> = ar_get(chCoolOn1, channel)]
The ar_get function returns a value from the array chCoolOn1 at index channel. It stores this value in the <$COOLANT-ON-1> reserved word, so that modality brackets can be used.
The corresponding line in ModalitySave would be:
[:ar_set(chCoolOn1, channel, <COOLANT-ON-1>)]
Here, the ar_set function stores the value of <COOLANT-ON-1> in the array chCoolOn1 at index channel. This saves that value for use later.
Generally, ModalityLoad will be called at the beginning of Program Start, Tool Change, and Segment Start, while ModalitySave will be called at the end of those formats. The arrays used within the formats also need to be initialized in the Variables custom format. In initializing any array, a name and length convention should be observed. Specifically, if the array will hold per-channel information, its name should start with "ch". For per-tool post information, the name should start with "tp". The array length should be one more than the number of slots you need, so that index 1 can refer to channel/tool post 1 (this is a result of zero-based indexing of arrays).