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 cre­ating and destroying buffers; and the buffer line functions: GetBufLine, PutBufLine, InsBufLine, AppendBu­fLine, 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 element at index 0

PutBufLine(hbuf, 1, rec)  // store element at index 1


See: File Buffer Functions.