PSL enables you to specify whether code generated in one procedure can be passed to another procedure. Parameters can be passed as reference by value (one-way passing), reference by name (two-way passing), arrays, or objects.
Refer to the following sections for additional information.
General Guidelines
When calling another routine, ensure that the correct parameters (i.e., objects, required variables) are passed.
Whenever possible, a function or method should pass actual values as parameters instead of objects.
Pass input parameters as String, Number, Date, Time, or Boolean values and references.
Objects can add significant overhead when passed as parameters. The generated code cannot optimize objects into local variables when they are passed, because both the receiver and caller require a common structure.
Passing values instead of reference objects optimizes the code and improves code re-usabability, because the receiving method or function does not have to anticipate a particular class.
Acceptable: |
type RecordACN acn=Db.getRecord(“ACN”,”:CID”) do SUB(.acn) quit |
Preferred: |
type RecordACN acn=Db.getRecord(“ACN”,”:CID”) do SUB(acn.bal) quit |
This provides the following benefits:
Functions and/or methods are easier to test
PSL compiler optimization
Database IO optimization
However, by passing individual column values or references, the formal parameter lists will lengthen and possibly make the code more difficult to read. To enhance readability, the compiler accepts parameters on separate lines, with comments allowed on each line. Each line of the parameter list must end with a comma to instruct the compiler to continue to read lines. The closing parenthesis indicates the end of the parameter list.
Example
type RecordDEP dep=Db.getRecord(“DEP”,”:CID”)
type RecordCIF cif=Db.getRecord(“CIF”,”:ACN”)
do CHECK(dep.odt,dep.bal,dep.irn,cif.nam,cif.taxid)
CHECK(String ODT, // odt /REQ/MECH=VAL
Number BAL, // balance /REQ/MECH=VAL
Number IRN,
String NAM,
String TAXID)
set INT=BAL*IRN
set DATA=NAM_”, “_TAXID
*CID and ACN must be defined prior to the getRecord statements.
You can list parameters on separate lines (with comments allowed on each line) to increase readability. For example,
a (Number cid, // Account Number
String x, // String
Date date) // Date
is the same as:
a (Number CID, String x, Date date)