Moves data to a screen buffer and displays the data on the screen or other output destination. The AVM uses frames to display data. A frame describes how constant and variable data is arranged for display and data entry. You can let ABL construct default frames or you can explicitly describe frames and their characteristics.
DISPLAY {[ STREAM stream | STREAM-HANDLE handle ] [ UNLESS-HIDDEN ] } [ { expression [ format-phrase ] [ ( aggregate-phrase ) ] [ WHEN expression ] [ @base-field ] } | [ SPACE [ ( n ) ] ] |[ SKIP [ ( n ) ] ] ] ... { [ IN WINDOW window ] [ frame-phrase ] [ NO-ERROR ] } |
DISPLAY { [ STREAM stream | STREAM-HANDLE handle ] [ UNLESS-HIDDEN ] } record [ EXCEPT field ... ] { [ IN WINDOW window ] [ frame-phrase ] [ NO-ERROR ] } |
If expression is a simple field or variable, the AVM checks to see if that particular field or variable is used previously in the same frame. If it has, the AVM displays the field or variable in the same frame field as the earlier instance of that field or variable.
In array fields, array elements with constant subscripts are treated just as any other field. Array fields with no subscripts are expanded as though you had typed in the implicit elements.
If you reference a[i] in the same frame that you reference a or a[constant], a[i] overlays the appropriate frame field based on the value of i. It is displayed in a new frame field for a[i]. For example.
r-arry.p
/*1*/ DEFINE VARIABLE ix AS INTEGER NO-UNDO. /*2*/ FOR EACH SalesRep: /*3*/ DISPLAY SalesRep.SalesRep SalesRep.Region SalesRep.MonthQuota. /*4*/ DO ix = 1 TO 12: /*5*/ SET SalesRep.MonthQuota[ix] WITH 1 COLUMN. /*6*/ END. /*7*/ DISPLAY SalesRep.MonthQuota /*8*/ WITH FRAME a COLUMN 40 ROW 3 1 COLUMN. /*9*/ END. |
Here, month-quota[i] is referenced in the same frame that month-quota is referenced. That is, line 5 references month-quota[i] and line 3 references month-quota. Both references use the same frame. Therefore, instead of creating a new frame field for month-quota[i], the AVM uses the same frame fields created for the entire month-quota array.
In the next procedure, line 4 references only elements 1 and 2. Therefore, when the AVM tries to overlay month-quota[i] in line 6, there is only room for elements 1 and 2. The AVM returns an error after you enter data for those two elements.
r-arry2.p
/*1*/ DEFINE VARIABLE ix AS INTEGER NO-UNDO. /*2*/ FOR EACH SalesRep: /*3*/ DISPLAY SalesRep.SalesRep SalesRep.Region /*4*/ SalesRep.MonthQuota[1] SalesRep.MonthQuota[2]. /*5*/ DO ix = 1 TO 12: /*6*/ SET month-quota[ix] WITH 1 COLUMN. /*7*/ END. /*8*/ DISPLAY month-quota WITH FRAME a COLUMN 40 ROW 3 1 COLUMN. /*9*/ END. |
The following example shows a solution to that problem:
r-arry3.p
/*1*/ DEFINE VARIABLE ix AS INTEGER NO-UNDO. /*2*/ FOR EACH SalesRep: /*3*/ DISPLAY SalesRep.SalesRep SalesRep.Region /*4*/ SalesRep.MonthQuota[1] SalesRep.MonthQuota[2] WITH 6 DOWN. /*5*/ FORM ix SalesRep.MonthQuota[ix]. /*6*/ DO ix = 1 TO 12: /*7*/ DISPLAY ix NO-LABEL. /*8*/ SET SalesRep.MonthQuota[ix]. /*9*/ END. /*10*/ DISPLAY month-quota WITH FRAME a COLUMN 40 ROW 3 1 COLUMN. /*11*/ END. |
If you explicitly reference a[ix] in a FORM statement, regular array fields (month-quota[1] and month-quota[2] in this example) are not overlaid.
{ AVERAGE | COUNT | MAXIMUM | MINIMUM | TOTAL | SUB-AVERAGE | SUB-COUNT | SUB-MAXIMUM | SUB-MINIMUM | SUB-TOTAL } ... [ LABEL aggr-label ] [ BY break-group ] ... |
For more information on aggregate-phrase, see the Aggregate phrase reference entry.
The AVM reserves enough space for the base-field to hold the longest format displayed there. All right-justified fields (numerics that do not use side labels) are right justified within the reserved area. The label is left or right justified according to the base-field. Whenever you enter data into the base-field, the AVM blanks out any characters to the left or right of the area used by the field being displayed.
The AVM underlines a screen area that is the longer of the base-field and the overlaying field. However, you can enter as many characters as there are spaces in the format of the field.
To determine the format to use for displaying the expression at the base-field, the AVM looks at the following and uses the first format that applies:
To display a record in a table defined for multiple databases, you must qualify the record's table name with the database name. See the record definition in the Record phrase reference entry for more information.
The DISPLAY statement, with NO-ERROR in effect, may continue to execute even if it encounters an error resolving some part of an expression. This attempt to complete the operation may result in displaying the empty string at the location of the intended output.
This procedure generates a hierarchical report of Customers (sorted by state and name), the orders belonging to those Customers, and the order-lines belonging to each order:
r-disp.p
FOR EACH Customer NO-LOCK BY Customer.State BY Customer.Name: DISPLAY Customer.State Customer.CustNum Customer.Name. FOR EACH Order OF Customer NO-LOCK: DISPLAY Order.OrderNum Order.Name Order.ShipDate Order.PromiseDate. FOR EACH OrderLine OF Order NO-LOCK, Item OF OrderLine NO-LOCK: DISPLAY OrderLine.LineNum Item.ItemName OrderLine.Qty OrderLline.price. END. END. END. |
This procedure lists each order, Customer information, and the OrderLines for each Order. The procedure calculates an Order-value for each of the OrderLines of an Order, and adds those values to produce a total value for an entire Order.
r-disp2.p
FOR EACH Order NO-LOCK, Customer OF Order NO-LOCK: DISPLAY Order.OrderNum Customer.Name Order.ShipDate Order.PromiseDate. FOR EACH OrderLine OF Order NO-LOCK, Item OF OrderLine NO-UNDO: DISPLAY OrderLine.LineNum Item.ItemName OrderLine.Qty OrderLine.Price OrderLine.Qty * OrderLine.Price (TOTAL) LABEL "Order-value". END. END. |
The r-disp3.p procedure displays a name and address list in a mailing label. The SKIP and FORMAT options are used to produce a standard address format. The WHEN option suppresses the display of the PostalCode field if there is no postal code value in the field.
r-disp3.p
ACCUM function, Aggregate phrase, DEFINE BROWSE statement, DEFINE FRAME statement, DOWN statement, EXPORT statement, FORM statement, Format phrase, Frame phrase, MESSAGE statement, NO-ERROR option, PAGE statement, PUT statement, PUT SCREEN statement, Stream object handle, UP statement, VIEW-AS phrase