PSL requires that you define each procedure as public, private, or include no line tag.
A Public label can be called by any other procedure regardless of the functionality calling into the line tag. These labels can be published. The PSL compiler incrementally loads data accessed in the subroutine or function.
A Private label indicates that the label can be accessed by a limited number of subroutines and functions outside the source file. The calling routines and the called label usually belong to a group of modules that provide related functionality. Private labels are not published or available for general use. Because private labels are accessed from outside the module, the PSL compiler treats them similar to public labels.
A Local label is a label that is declared neither public nor private. It is the default access mode. Local labels can only be accessed by subroutines and functions inside the current PSL module. The PSL compiler may suppress incremental data loading if it can infer that the data accessed in the subroutine or function has already been loaded elsewhere in the source module.
Declaring Procedures
In PSL, you must identify a procedure as a public procedure or a private procedure in order for the compiler to generate code that can be called from other source files. The syntax of these declarations appears below. Although the keywords public, private, and local are not case-sensitive, it is recommended that you use all lowercase for keyords.
Public: |
public PROC (type identifier) |
Private: |
private PROC (type identifier) |
Local: |
PROC (type identifier) |
The keyword local is reserved to explicitly identify local labels. Recognition of this keyword will be implemented in the near future. The code generated by the PSL compiler does not yet prevent calls to local labels from outside the routine. This too will be implemented in the near future. |
Example
The following example illustrates how the cif object is passed to the CHECK and CHECK1 procedures. The calling procedure defines the cif object as type RecordCIF. The CHECK and CHECK1 procedures also define parameters of type RecordCIF to receive the object.
set ACN = Db.currVal("CIF")
type RecordCIF cif = Db.getRecord(“CIF”,”ACN=:ACN”)
set city = cif.mcity
do CHECK(.cif)
do CHECK1(.cif)
quit
CHECK(RecordCIF cif) // Loads only missing nodes
set state = cif.mstate
set taxid = cif.taxid
write city,!,state,taxid
quit
public CHECK1(RecordCIF cif) // Loads all nodes after
// performing a check
set zip=cif.mzip
set taxid=cif.taxid
write taxid,!,zip
quit
In addition, this code illustrates how private and public procedures load data. When the private procedure (CHECK) processes, it only loads data from nodes that have not been previously loaded by the calling procedure (taxid). That is, because the mcity column appears on the same node as the mstate column in the CIF table, the compiler does not reload that node.
However, because CHECK1 is a public procedure and can therefore be processed at any time (i.e., not necessarily immediately following this calling procedure), the compiler loads data from all nodes of the CIF table that are referenced inside the subroutine. It does, however, perform a check, to see if the node has been previously loaded in the calling procedure. If so, then it does not reload the node.