【问题标题】:Openedge 4gl Display 2 For each?Openedge 4gl 显示 2 每个?
【发布时间】:2018-11-22 02:52:49
【问题描述】:

假设每个语句有 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|

怎么做?

【问题讨论】:

    标签: openedge progress-4gl


    【解决方案1】:

    如果您为两个框架指定宽度和 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.        
    

    【讨论】:

      【解决方案2】:

      由于表格不相关,您必须进行一些数据操作才能获得您正在寻找的并排图表输出。您可以创建一个“行”临时表,其中包含要在每个输出行中显示的四个字段。遍历每个表,将记录数据添加到每一行。然后遍历线路临时表,输出线路数据。

      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.
      

      上面的例子应该给你你正在寻找的输出。它还将处理每个表中的记录数不同的情况。它会在没有数据的地方留下空白。

      【讨论】:

      • 不,您可以自己设置展示位置。请参阅 Mike 的答案。
      猜你喜欢
      • 2017-07-18
      • 2012-03-19
      • 2018-03-14
      • 2014-03-19
      • 2019-01-28
      • 1970-01-01
      • 2017-09-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多