General
Minimize the use of Public scope variables. When used, clearly document and publicly type Public scope variables.
Explicitly type (i.e., do not new) and alphabetize all variables when they are on the same line.
Only Public scope variables may be used in function system variables.
Use Literal scope variables for static variables (e.g., in the column list of the Db.select method).
Use variables consistently within other areas of the system.
Kill all "garbage" variables prior to completing a batch. Batches should exit without any variables specific to the batch program left behind. Variables used in the open section should be killed in the Schexit section.
Variable Syntax
PSL variable names cannot exceed eight characters in length.
Do not use v or V as the first letter in object or variable names. The compiler reserves these characters to prefix object storage data structures.
Do not use the following characters when naming variables:
Control characters
Period
Comma
Space
Underscore
PSL has specific interpretations for each of these characters. For example, PSL interprets commas and spaces as expression delimiters; underscores as string concatenators; and periods as extension delimiters.
Apply the following guidelines when choosing variable names for primitive datatypes and reference datatypes:
Primitive - Use all uppercase letters in variable names. Variable names start with an alpha character or the percent character (%), and may be followed by up to 7 alpha characters or digits. Names are case sensitive.
Reference - Use all lowercase letters in variable names.
Example
type RecordCIF cif = Db.getRecord(“CIF”,”:ACN”)
set NAM = cif.lnm
set DOB = cif.dob
set TAXID = cif.taxid
________________________________________________________
type ResultSet rs = Db.select(“CID,BAL,IRN”,”DEP”)
while rs.next() do {
set data = rs.getRow()
set CID = rs.getCol(1)
set INT = rs.getCol(1) * rs.getCol(2)
}
Host Variables
Methods that accept parameters that define the access keys (accessKeys) or an SQL WHERE clause (whereClause) must use host variables. That is, the parameter must be preceded by a colon (:). Previously, it was acceptable to use named variables.
Example
Unacceptable: |
type RecordACN acn = Db.getRecord("ACN","CID") |
Acceptable: |
type RecordACN acn = Db.getRecord("ACN",":CID") |
Example
Unacceptable: |
type ResultSet rs = Db.select("ETC,TAMT","HIST","CID=CID ...AND TAMT>XAMT") |
Acceptable: |
type ResultSet rs = Db.select("ETC,TAMT","HIST","CID=:CID ...AND TAMT>:XAMT") |
When Standard is Enforced: v7.0