Progress
Language Reference


CREATE BROWSE Statement

Interfaces
OS
SpeedScript
Graphical only
Windows only
No

Creates a dynamic browse, either read-only or updateable. Browse columns are added with the ADD-LIKE-COLUMN, ADD-COLUMNS-FROM, and ADD-CALC-COLUMN methods. The query is specified through the QUERY attribute.

The dynamic updateable browse can only be a NO-ASSIGN browse — all data assignments to the database must be done by the 4GL programmer.

SYNTAX

CREATE BROWSE widget-handle
  [ IN WIDGET-POOL widget-pool-name ]
  [ ASSIGN { attribute=expression } ... ]
  [ trigger-phrase ] 

widget-handle

A variable of type WIDGET-HANDLE that Progress sets to the value of the new widget handle.

IN WIDGET-POOL widget-pool-name

Specifies the widget pool in which the object is created. If you do not specify a widget pool, the object is created in the current default widget pool. The browse will go away when its widget pool goes away or when you do a DELETE OBJECT on it.

ASSIGN { attribute = expression } ...

Assigns specified values to attributes of the object. The attribute parameter must be the name of a valid attribute for the object and expression must evaluate to a valid value for that attribute.

trigger-phrase

A trigger phrase associated with the object. For more information, see the Trigger Phrase reference entry.

EXAMPLE

The following example creates a dynamic browse and adds columns to it.

r-dynbrws.p
/* r-dynbrws */
DEFINE VARIABLE name-hdl AS WIDGET-HANDLE.
DEFINE VARIABLE num-hdl AS WIDGET-HANDLE.
DEFINE VARIABLE address-hdl AS WIDGET-HANDLE.
DEFINE VARIABLE calc-col-hdl AS WIDGET-HANDLE.
DEFINE VARIABLE browse-hdl AS WIDGET-HANDLE.
DEFINE VARIABLE buff-field-hdl AS WIDGET-HANDLE.
DEFINE VARIABLE brws-col-hdl AS WIDGET-HANDLE.
DEFINE BUTTON btn-delete LABEL "Delete".
DEFINE BUTTON btn-quit LABEL "&Quit"  AUTO-ENDKEY.
DEFINE VARIABLE j AS INTEGER.

DEFINE FRAME MyFrame SKIP(10)
             btn-delete btn-quit
       WITH SIZE 80 BY 22.

DEFINE QUERY q1 FOR customer SCROLLING. 
OPEN QUERY q1 FOR EACH customer NO-LOCK.

CREATE BROWSE browse-hdl
    ASSIGN TITLE = "Dynamic Browse"
           FRAME = FRAME MyFrame:HANDLE
           QUERY = QUERY q1:HANDLE
           X = 2
           Y = 2
           WIDTH = 74
           DOWN = 10
           VISIBLE = YES
           SENSITIVE = TRUE
           READ-ONLY = NO. 
ON row-display OF browse-hdl DO:
  IF VALID-HANDLE(calc-col-hdl) THEN
    calc-col-hdl:SCREEN-VALUE = 
                 STRING(customer.credit-limit - customer.balance).
END.

num-hdl = browse-hdl:ADD-LIKE-COLUMN("customer.cust-num").
name-hdl = browse-hdl:ADD-LIKE-COLUMN("customer.name").
address-hdl = browse-hdl:ADD-LIKE-COLUMN("customer.address").
calc-col-hdl = browse-hdl:ADD-CALC-COLUMN("INT","->,>>>,>>9.99","","Credit 
Left").

/* Refresh needs to be done if ADD-CALC-COLUMN is done after the browse
* is displayed. In ROW-DISPLAY trigger, we can only set the calc field’s
* screen-value if the handle is set. And the handle is set after the
* ADD-CALC-COLUMN method is done. */

browse-hdl:refresh().
browse-hdl:EXPANDABLE = YES.

ON row-leave OF browse-hdl DO:
    IF browse-hdl:CURRENT-ROW-MODIFIED THEN DO:
        REPEAT j = 1 TO browse-hdl:NUM-COLUMNS:
            brws-col-hdl = browse-hdl:GET-BROWSE-COLUMN(j).
            IF brws-col-hdl:MODIFIED THEN DO:
                buff-field-hdl = brws-col-hdl:BUFFER-FIELD.
            /* if buff-field-hdl is unknown, this is a calculated field
                  and cannot be updated */
                IF buff-field-hdl NE ? THEN
                    buff-field-hdl:BUFFER-VALUE = 
                                   brws-col-hdl:SCREEN-VALUE.
            END.
        END.
    END.
END.

ON CHOOSE OF btn-delete DO:   /*  LABEL "DeleteDynBrowse". */
    DELETE WIDGET browse-hdl.
END.

ON CHOOSE OF btn-quit DO:
    QUIT.
END.

ENABLE ALL WITH FRAME MyFrame.
WAIT-FOR CLOSE OF CURRENT-WINDOW. 

NOTES

SEE ALSO

ADD-CALC-COLUMN() Method, ADD-COLUMNS-FROM( ) Method, ADD-LIKE-COLUMN( ) Method, CREATE QUERY Statement, CREATE Widget Statement, DEFINE BROWSE Statement, DEFINE QUERY Statement, GET-BROWSE-COLUMN( ) Method, QUERY Attribute


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