Openedge 4gl Display 2每个?

时间:2018-11-22 02:52:50

标签: openedge progress-4gl

假设每个语句有2个,而没有2个相关表 第一个是

for each table-1 
   disp table-1.col1 
        table-1.col2.
end. 

for each table-2
   disp table-2.col1
        table-2.col2.
end.

它像这样向我显示

table-1.col1 table-1.col2 
table-1.col1 table-1.col2
table-1.col1 table-1.col2

table-2.col1 table-2.col2
table-2.col1 table-2.col2
table-2.col1 table-2.col2

我希望它显示为

---------- Table 1 ---------      ---------- Table 2 --------
|table-1.col1 table-1.col2 |      |table-2.col1 table-2.col2|      
|table-1.col1 table-1.col2 |      |table-2.col1 table-2.col2|
|table-1.col1 table-1.col2 |      |table-2.col1 table-2.col2|

该怎么做?

2 个答案:

答案 0 :(得分:4)

如果您为两个框架指定宽度和col(umn),则可以控制将其显示为彼此相邻。

for each Salesrep:                                                                      
   display salesrep.salesrep                                                            
           salesrep.repname                                                             
       with down frame frm-salesrep                                                     
       width 40.                                                                        
end.                                                                                    

for each Item:                                                                          
    display item.ItemNum                                                                
            item.ItemName                                                               
       with down frame frm-item                                                         
       col 41.                                                                                    
end.        

答案 1 :(得分:0)

由于这些表是不相关的,因此您必须进行一些数据操作以获取所需的并排图表输出。您可以创建一个“行”临时表,其中包含要在每条输出行上显示的四个字段。浏览每个表,将记录数据添加到每一行。然后浏览行临时表并输出行数据。

DEFINE VARIABLE linecnt AS INTEGER NO-UNDO.

DEFINE TEMP-TABLE ttLine
    FIELD linenum AS INTEGER
    FIELD tbl1col1 AS CHARACTER
    FIELD tbl1col2 AS CHARACTER
    FIELD tbl2col1 AS CHARACTER
    FIELD tbl2col2 AS CHARACTER
    INDEX Idx1 IS PRIMARY linenum.

linecnt = 1.  /* Initialize the line counter. */

/* Go thru table-1, creating a ttLine for each record. */
FOR EACH table-1 NO-LOCK:
    CREATE ttLine.
    ASSIGN
        ttLine.linenum = linecnt
        ttLine.tbl1col1 = table-1.col1 
        ttLine.tbl1col2 = table-1.col2
        linecnt = linecnt + 1.
END. 

linecnt = 1.  /* Reset the line counter. */

/* Go thru table-2, adding data to ttLine and creating new records if necessary. */
FOR EACH table-2 NO-LOCK:
    FIND FIRST ttLine WHERE ttLine.linenum = linecnt NO-ERROR.
    IF NOT AVAILABLE(ttLine) THEN
    DO:
        CREATE ttLine.
        ttLine.linenum = linecnt.
    END.

    ASSIGN
        ttLine.tbl2col1 = table-2.col1
        ttLine.tbl2col2 = table-2.col2
        linecnt = linecnt + 1.
END.

/* Go thru ttLine, output data. */
OUTPUT TO VALUE("output.txt").

PUT UNFORMATTED
    "---------- Table 1 ---------      ---------- Table 2 --------"
    SKIP.

FOR EACH ttLine:
    PUT UNFORMATTED
        "|" + 
        STRING(ttLine.tbl1col1, "X(12)") + " " + STRING(ttLine.tbl1col2, "X(12)") + 
        " |      |" +
        STRING(ttLine.tbl2col1, "X(12)")  + " " + STRING(ttLine.tbl2col2, "X(12)") + 
        "|" 
        SKIP.
END.

OUTPUT CLOSE.

上面的示例应为您提供所需的输出。它还可以处理每个表中没有相同记录数的情况。它将在没有数据的地方留下空白。

相关问题