Programming with LPL
Pointers
Using the LI-6400 22-19
pointer array. Each of these unnamed PTR arrays has the same size (2 ele-
ments) (but they donÕt have to); the first element is an unnamed INT array,
and the second is a named object.
PTR arrays can also be used to collect unnamed strings, and even unnamed
functions. Figure 22-8 declares a 2 element PTR array named x. The first el-
ement is a string, and the second is a function. The Main function makes the
second element operate on the first.
This program will result in
***** This is a test *****
being printed to the display.
Passing Parameters
PTRs and PTR arrays have many uses in LPL programs. Figure 22-9 illus-
trates the use of PTRs to handle function parameters. In this program, the
function named Go expects to find three items on the stack waiting for it.
:PTR x[] {
"This is a test"
:FCT { "***** %s *****"
PRINT }
}
:FCT main
{
/* Put string on stack. */
x 1
PICK
/* Puts fct address on stack, then execute */
x 2 PICK CALL
}
Figure 22-8. PTR arrays can contain unnamed objects.