Using the QX data storage array

The QX array is used for all major data storage in the Xtal System. Data is stored contiguously in QX, so that new data is added to higher and higher index values of the array. The advantages of this approach are that

  • unlike multi-dimensioned arrays, the size of QX need not be redefined for different sized calculations. It is assumed that this array is open-ended.

  • the data is close-packed. This is very important for machines with either virtual memory or dynamic memory allocation operating systems.

  • address calculation of elements in a single-dimensioned array is usually more efficient than to a multi-dimensioned array.

Well-tried procedures for storing data in the QX array as 'lists', subdivided into 'packets' and 'subpackets', provide powerful and conceptually simple ways for manipulating data. The boundaries of these lists and packets may be either simple 'mark' and 'step' variables (e.g. see the program FC) or specially designed macro pointers that identify each item in the stored list (e.g. see the program MODEL). The storage of data in the QX array is assisted by macro tools that move word and character strings within the QX array (these are detailed in the next chapter).

Because the QX array is defined as floating-point words, a special approach needed for storing packed-integer and character data. Packed-integer data is stored and extracted with the intpak: and intunpak: macros which are specifically designed to manipulate integers in a floating-point word. Character data are stored in the QX array using the movector: character-to-real macro, and retrieved via the movertoc: real-to-character macro. Also, the movereal: macro is available to transfer strings of words, independent of gender (i.e. real, packed-integer or character).

The way in which the QX array is referenced is an important aspect of programming Xtal software. It will be discussed briefly here and elaborated on in the qxmemory: section of the next chapter. The QX array should always be addressed via a relative index. The 'start' (i.e. lowest) value of this index is set by the variable QXSTR which is set initially to 1. When new data is to be added to the QX array, a test must be made using qxmemory: or incrqx: to ensure that sufficient memory is available for the next packet of data. These macros check against the preset maximum QX array definition memmax:. Further details on memory allocation are provided in the next chapter.