Use the following guidelines when formatting programming code:
General
Use lowercase PSL syntax instead of uppercase M commands.
Use PSL keywords in place of M variables. Refer to the System Keywords section for a list of system keywords.
Group operations with parentheses when appropriate, to avoid any unexpected results.
Line Tags
Line tags must start on the first column.
Line tags must be labeled with private, public, or not at all.
Public line tags are accessible to other procedures regardless of the functionality calling into the line tag (e.g., utility line tags). The compiler treats this line tag as being called from an external procedure and generates code accordingly.
Private line tags are not reusable to other procedures. Although these line tags are called from external procedures, they are considered supporting functions or sub-procedures of the calling procedure. The compiler treats this line tag as being called from an external procedure and generates code accordingly.
Line tags not labeled public or private are considered local. These line tags are called only from within the same procedure and are not for external use.
Code Blocks
Ensure that all loops terminate.
Define all structured blocks with open and close brackets.
Use tabs for each level of a new block of code.
If logic is reusable, use new subroutines instead of structured blocks of code.
Move subroutines that have a single caller, into the caller as a code block. The #OPTIMZE command works better in that situation, and the actual code execution (net of PSL) is significantly faster if the code is adjacent, rather than in a separate label or program.
Align If/Else pairs.
Scope
Whenever appropriate, CUVAR properties and other static tables should be scoped as "Literal" objects in PSL source. Using CUVAR.<columnName> within a PSL program for columns that do not change will enable the compiler to generate code that contains the value of the field and then prevents run-time lookup of that information.
Run-time indirection and execution of Record<class> columns should be avoided when possible. It impacts performance by having to determine the location of the column within the record at runtime rather than compile time. Use Literal scope to minimize, if possible.
Exclusive scope (e.g., new(a,b,c)) is prohibited.