Declaring Procedures

PSL requires that you define each procedure as public, private, or include no line tag.

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.