|DISPLAY and MOVE in SQR||KEVIN RESCHENBERG|
DISPLAY and MOVE are two of the most commonly used commands in SQR. My recommendation: Don't use them.
DISPLAY is used to write information to the log, generally for tracing or error notification purposes. It works just fine, but
it's limiting. To display a number in a specified format, you would need to code the following:
let $amount = edit(#amount, '999,999.00')
display 'Amount = ' noline
So what's the alternative? Use SHOW:
show 'Amount = ' #amount edit '999,999.00'
DISPLAY handles one variable or literal at a time. It can do very limited formatting. SHOW, on the other hand, can use all of the
capabilities of EDIT, can write many variables and/or literals at once, and can even position the cursor.
The situation is similar with MOVE. MOVE can take one variable or literal and assign it to a variable. The alternative, LET,
is far more flexible. It can use functions (including EDIT()) and calculations. Instead of:
move 1 to #sum
add 1 to #sum
we can say:
let #sum = 1 + 1
There is one oddity: If your variable contains an embedded "$" or "#" in its name, LET won't work:
let $account# = '123' ! Error
move '123' to $account# ! OK
Avoid this by keeping "$" and "#" out of your variable names (except, of course, as the first character).
Avoid the old COBOL-like commands in favor of the more flexible alternatives, and your code will not only be easier to write,
but also cleaner and easier to read.