EasyManua.ls Logo

LI-COR LI-6400 - Ptrs and Files; Using PTR Arrays

LI-COR LI-6400
846 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Programming with LPL
Pointers
Using the LI-6400 22-21
a PTR to it. The example in Figure 22-10 opens a file, writes two lines of text
to it, and closes the file.
For an example of using PTR arrays, we revisit Figure 22-9 on page 22-20,
and rewrite the program as follows:
The PTR array xxx has 4 elements, each one of which is an unnamed PTR
array having 3 elements. Main goes through the array calling Go2 with each
element found in xxx. Go2 receives 1 parameter, which it assumes is a PTR
array with 3 elements: 1) the label, 2) the symbol, and 3) the function to exe-
cute.
:FCT Main
{
"w" "test file"
OPEN_FILE IF RETURN THEN
:PTR file
"This is a new file\n" "%s" file
PRINT
"The end." "%s" file PRINT
file CLOSE
}
Figure 22-10. PTRs and files.
:PTR xxx[]
{
:PTR { "Add" "+" :FCT { + } }
:PTR { "Subtract" "-" :FCT { - } }
:PTR { "Multiply" "*" :FCT { * } }
:PTR { "Divide" "/" :FCT { / }}
}
:FCT Main
{
1
:INT i
xxx
READY NLOOP
xxx i PICK Go2
&i 1 +
DROP
ENDLOOP
GETKEY DROP
}
Go2
{
:PTR info
1.23
:FLOAT x
5.67
:FLOAT y
info 1
PICK "%s: " PRINT
x y info 3 PICK CALL :FLOAT result
result y info 2
PICK x "%g %s %g = %g\n" PRINT
}
Figure 22-11. Using PTR arrays

Table of Contents