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