Line Continuation
To make long lines of ProcScript easier to read and maintain, you can use the line
continuation marker (%\
). Place the marker at the end of a line, directly followed
by a carriage return (or spaces, tabs, a comment and a carriage return).
The line continuation marker causes Uniface to
ignore the carriage return and continue at the next line as if it were part of the previous line.
Line continuation markers are processed before any other types of syntax; even before comment
markers (;
).
Line continuation markers can be used anywhere in a line of ProcScript, including SQL statements, strings, comment, and literals, such as function names or field names, as shown in the following examples.
Note: Line continuation is not allowed for precompiler directives such as #define; these must occur on a single, physical line.
String Assignment Over Multiple Lines
The following ProcScript example shows a string assignment divided over multiple lines:
$1 = "Once upon a time, there was a line in a ProcScript that was %\ many miles long. It was a very unhappy line because the %\ nasty compiler had cut it into many pieces and returned an %\ error, which meant that the line could do nothing at all.%\ Indeed, the whole ProcScript was powerless against the might of %\ the compiler. But then a great symbol arrived, bearing the %\ banner of continuation, which joined all the bits together %\ again and made everybody very happy."
Expression Assignment Over Multiple Lines
The following ProcScript example shows the assignment of an expression divided over multiple lines:
RESULT = FIELD1 + FIELD2 + FIELD3 + %\ FIELD4 + FIELD5 + FIELD6
The following ProcScript example shows the same, but splits the line in the middle of a field name:
RESULT = FIELD1 + FIELD2 + FI%\ ELD3 + FIELD4 + FIELD5 + FIELD6
Statements Over Multiple Lines
The following ProcScript example divides a long statement over multiple lines making it more readable:
selectdb (max(INV_NUM), sum(AMOUNT)) %\ from "INVOICE" %\ u_where (CUSTOMER = $1) %\ to ($2, TOTAL_DUM)
The following ProcScript example divides a complex statement over multiple lines making it more readable:
; Compilation results filter $1 = 4 ; Show me phase 4 only putmess "Phase %%$1:%%^ %\ %%$putmess[ $scan($putmess, "Phase %%$1") + %\ $scan( $putmess[ $scan($putmess, "Phase %%$1")], "%%^"), %\ $scan($putmess, "Phase %%$expression("%%$1 + 1")") - 1]"
Comment Over Multiple Lines
The following ProcScript example shows a comment line divided over multiple lines:
; My comment starts here, %\ continues on this line, %\ and ends on this line.
Empty Line Stops Continuation
The following ProcScript example shows that an empty line stops continuation:
; My comment starts here, %\ continues on this line, %\ and ends on the next empty line. %\ putmess "This line is not part of the comment."
The empty line does not contain a continuation marker, therefore the line after the empty line is not part of the comment line.
Interpretation of Multiple Spaces
The following ProcScript example shows the way multiple spaces in a row (or tabs), used at the beginning of a continued line, are interpreted differently in statements versus strings:
; The spaces before and after FIELD5 are ignored, they do not matter $1 = FIELD1 + FIELD2 + FIELD3 + FIELD4 + %\ FIELD5 + FIELD6 + FIELD7 + FIELD8
; The spaces in the string are not ignored, they do matter $1 = "%%FIELD1, %%FIELD2, %%FIELD3, %%FIELD4, %\ %%FIELD5, %%FIELD6, %%FIELD7, %%FIELD8"