我认为使用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 和#start-line-offset 的原因是因为#current-line 是报告中的当前行位置包括标题的偏移量。例如,如果您的标题有 5 行高,那么 #current-line 将开始等于 6(您的标题之后的第一行),并且执行 PRINT 'hello' (#current-line, 1) 实际上将打印到报告的第 11 行(从 5 行向下 6 行)行标题)。此外,为#current-line 赋值似乎不起作用,所以我认为您不能直接操纵当前行位置。
但是,如果您不需要在三列之后打印任何其他内容,那么您可以使用 KEEP-TOP 参数到 WRAP 以便您当前的行位置不会在每个 PRINT 和您不必进行任何线偏移跟踪。
在您的情况下,您必须根据文本和列位置数据在该字段中的存储方式,将 &TXT.PO_TXT 解析为三个单独的变量(每列一个)。
需要注意的一点是,如果在打印的数据中连续有两个或多个空格,SQR 可能会将空格作为一行的第一个字符,因为分词似乎仅由第一个空格,而不是一个或多个空格的序列。