Progress
Programming
Handbook


The Buffer Object

The buffer object corresponds to an underlying Progress buffer, which can be static or dynamic. A static buffer is one you define at compile time by using the DEFINE BUFFER statement, or by implicitly referencing a table in a 4GL construct such as customer.cust-num. A dynamic buffer is one you create at run time using the BUFFER option of the CREATE Widget statement.

The buffer object, like the query object and other Progress objects, is represented by a variable of type HANDLE. You can use a HANDLE variable to acquire a new buffer object as the following code fragment demonstrates:

DEFINE VARIABLE my-buffer-handle AS HANDLE.
CREATE BUFFER my-buffer-handle FOR TABLE "mycusttab".
... 

You can also use a HANDLE variable to acquire a buffer object for an existing statically-created buffer, as the following code fragment demonstrates:

DEFINE VARIABLE my-buffer-handle AS HANDLE.
my-buffer-handle = BUFFER customer:HANDLE.
... 

With the buffer object you can:

The following program example demonstrates the use of buffer objects in a dynamic query. Note the use of the dynamic predicate (WHERE and BY clauses) in the query:

p-qryob1.p
/* p-qryob1.p - demonstrates buffer and query objects */

DEFINE VARIABLE qry1 AS HANDLE.
DEFINE VARIABLE wherev AS CHARACTER INITIAL "WHERE cust-num < 10".
DEFINE VARIABLE sortv AS CHARACTER INITIAL "BY sales-rep".
DEFINE VARIABLE bval AS LOGICAL.
DEFINE VARIABLE i AS INTEGER.
DEFINE VARIABLE bh AS WIDGET-HANDLE EXTENT 4.

CREATE QUERY qry1.

REPEAT:
    UPDATE wherev FORMAT "x(70)"
      LABEL "Enter WHERE and BY information."  SKIP
            sortv FORMAT "x(70)" NO-LABEL.

    qry1:SET-BUFFERS(BUFFER customer:HANDLE, BUFFER order:HANDLE).
    bval = qry1:QUERY-PREPARE("FOR EACH customer " + wherev +
            ", EACH order OF customer " + sortv).

    REPEAT i = 1 TO qry1:NUM-BUFFERS:
        bh[i] =  qry1:GET-BUFFER-HANDLE(i).
        DISPLAY bh[i]:NAME.  /* display the buffer names */
    END.

    IF (bval = FALSE) THEN NEXT.
    qry1:QUERY-OPEN.

    REPEAT WITH FRAME fr1 ROW 8:
        qry1:GET-NEXT.
        IF (qry1:QUERY-OFF-END) THEN LEAVE.
        DISPLAY cust.cust-num cust.name cust.sales-rep
                  cust.state order.order-num.
    END.

    qry1:QUERY-CLOSE.
END.

DELETE OBJECT qry1. 

When the program pauses, press the GO key (usually F2) to continue.

Notes on Dynamic Buffers

Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095