我认为这不可能通过使用COLUMNS
. 定义和打印到 SQR 列决定了您开始打印的位置,但文本在到达列末尾时不会自动换行。它只会继续打印。
但是,您可以使用该WRAP
参数PRINT
来完成此操作。这是一个例子
LET $left = 'This is the left column. This is the left column. This is the left column. This is the left column. This is the left column. This is the left column.'
LET $middle = 'This is the middle column. This is the middle column. This is the middle column. This is the middle column. This is the middle column. This is the middle column. This is the middle column. This is the middle column. This is the middle column. This is the middle column. This is the middle column. This is the middle column.'
LET $right = 'This is the right column. This is the right column. This is the right column. This is the right column. This is the right column. This is the right column.'
! These variables are used to track which column is the tallest and then
! move the current position (#start-line) down by the largest number of
! lines that were printed
LET #line-offset = 0
LET #start-line = 1
LET #start-line-offset = #current-line - #start-line
! Print the left column
PRINT $left (#start-line, 1) WRAP 40 100
IF #current-line - #start-line-offset > #line-offset
LET #line-offset = #current-line - #start-line-offset
END-IF
! Print the middle column
PRINT $middle (#start-line, 50) WRAP 50 100
IF #current-line - #start-line-offset > #line-offset
LET #line-offset = #current-line - #start-line-offset
END-IF
! Print the right column
PRINT $right (#start-line, 110) WRAP 40 100
IF #current-line - #start-line-offset > #line-offset
LET #line-offset = #current-line - #start-line-offset
END-IF
! Update #start-line to be the original line position, plus the
! number of lines that were printed in the tallest column
LET #start-line = #start-line + #line-offset
PRINT 'Rest of the report goes here' (#start-line, 1)
后面的第一个数字WRAP
是该列的字符宽度。
后面的第二个数字WRAP
是要打印的最大行数。
我的代码中的大部分复杂性来自这样一个事实,即您必须跟踪哪一列打印的行数最多(垂直最大),然后将当前光标位置向下移动这么多行。困难来自这样一个事实,即您的最高列可能是左列或中列,因此您需要跟踪哪一列是您的最高列,而不是在打印右列后简单地向下移动光标。在我的示例中,中间的列是最高的。
我使用#line-offset
and#start-line-offset
的原因#current-line
是报告中的当前行位置,包括 header 的偏移量。例如,如果您的标题有 5 行高,则#current-line
开始等于 6(标题之后的第一行),doingPRINT 'hello' (#current-line, 1)
实际上将打印到报告的第 11 行(从 5 行标题向下的 6 行)。此外,分配一个值#current-line
似乎不起作用,所以我认为您不能直接操纵当前行位置。
但是,如果您不需要在三列之后打印任何其他内容,那么您可以使用KEEP-TOP
参数 toWRAP
以便您当前的行位置不会在每列之间更改,PRINT
并且您不必执行任何行偏移追踪。
在您的情况下,您必须&TXT.PO_TXT
根据文本和列位置数据在该字段中的存储方式解析为三个单独的变量(每列一个)。
需要注意的一点是,如果您正在打印的数据中连续有两个或多个空格,SQR 可能会将空格作为一行的第一个字符,因为分词似乎仅由第一个空格决定,而不是一个或多个空格的序列。