User Tools

Site Tools


using_20data_20statements_20in_20libraries

Using DATA statements in libraries

by Richard Russell, March 2011

Because you cannot use line numbers or labels in libraries (or other INSTALLed modules), the conventional forms of the RESTORE statement cannot be used. At first sight it might appear that this precludes the use of DATA statements in libraries, but in fact they can be used by means of the relative version RESTORE +.

For example the following code could be placed in a library:

        DEF PROCrestore
        RESTORE +1
        ENDPROC
        DATA Here,are,some,data,items,in,a,library
        DATA Here,is,some,more,data

Calling PROCrestore moves the data pointer so that the next items to be READ will be taken from the subsequent DATA statements:

        PROCrestore
        READ A$,B$,C$,D$

(this code could be in the main program or in a library).

Note the use of RESTORE +1 rather than RESTORE +2, as might superficially seem more correct. This ensures that the code will work correctly even if the library is crunched using the concatenate lines option (resulting in the ENDPROC being moved onto the same line as the RESTORE).

If you find that disconcerting you could always move the ENDPROC until after the DATA statements:

        DEF PROCrestore
        RESTORE +1
        DATA Here,are,some,data,items,in,a,library
        DATA Here,is,some,more,data
        ENDPROC
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
using_20data_20statements_20in_20libraries.txt · Last modified: 2024/01/05 00:21 by 127.0.0.1