Array Techniques

The Source Insight macro language does not support array variables. However, file buffers can be used as dynamic arrays. Each line in a buffer can represent an array element. Furthermore, record variables can be stored in each line to give you record arrays.

Buffer functions are described in a following section. Some useful functions are NewBuf and CloseBuf for creating and destroying buffers; and the buffer line functions: GetBufLine, PutBufLine, InsBufLine, AppendBufLine, DelBufLine, and GetBufLineCount. You can also call NewWnd to put the array buffer in a window so you can see the array contents.

This example creates a buffer array of records.

hbuf = NewBuf()
rec = “name=\”Joe 
Smith\”;age=\”34\”;experience=\”guru\””
AppendBufLine(hbuf, rec)
rec = “name=\”Mary 
X"\”;age=\”31\”;experience=\”intern\””
AppendBufLine(hbuf, rec)
// hbuf now has 2 records in it
…
rec = GetBufLine(hbuf, 0) // retrieve 0th element
CloseBuf(hbuf)

In this section: