Consultor Eletrônico



Kbase P66324: Where can I find sample code of a Browse Programming Example
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   05/02/2004
Status: Unverified

GOAL:

Where can I find sample code of a Browse Programming Example in character mode?

FIX:

/**********

The following is a TTY character mode 'Browse Programming Example' along with numbered notes explaining the highlights of the program. Both the program and the notes have been extracted from the 'Progress Language Tutorial for Character'.

1. To use a browse with a query, include the SCROLLING option on the DEFINE QUERY statement.
2. This statement defines the browse widget, the fields it displays, and the number of rows it shows at one time. The ENABLE option defines this as an updatable browse where all fields except Item-Num can be changed.
3. These statements define the widgets and frames for the procedure.
4. This statement defines the trigger for button btn-Add.
5. This DO statement executes when changing focus from a row in browse Item-Browse. For new records, the IF...THEN statement updates the browse.
6. The INPUT BROWSE option of the ASSIGN statement writes the new information to the database.
7. The CREATE-RESULT-LIST-ENTRY( ) method updates the query results list to match the browse and database.
8. This statement displays the Item-Num assigned to a new record by the database.
9. This DELETE trigger on button btn-Delete deletes the selected rows.

**********/

/********** DEFINE QUERY **********/
/*1*/ DEFINE QUERY Item-Query FOR Item SCROLLING.
/********** DEFINE VARIABLES **********/
DEFINE VARIABLE Method-Status AS LOGICAL.
DEFINE VARIABLE Current-Record AS ROWID.
/********** DEFINE BROWSE **********/
/*2*/ DEFINE BROWSE Item-Browse QUERY Item-Query DISPLAY Item-Num
Item-Name Price On-hand Cat-Description WIDTH 18
ENABLE Item-Name Price On-hand Cat-Description WITH 10 DOWN
SEPARATORS.
/********** DEFINE WIDGETS **********/
/*3*/ DEFINE BUTTON btn-Add LABEL "Add".
DEFINE BUTTON btn-Delete LABEL "Delete".
DEFINE BUTTON btn-Exit LABEL "Exit".
/********** DEFINE FRAMES **********/
DEFINE FRAME Frame1
btn-Add AT COLUMN 2 ROW 12 btn-Delete btn-Exit SKIP(1)
Item-Browse AT ROW 2 COLUMN 2
WITH SIDE-LABELS USE-TEXT CENTERED THREE-D
ROW 2 TITLE "Database Access Form for the Item Table".
/********** DEFINE TRIGGERS **********/
/*4*/ ON CHOOSE OF btn-Add DO:
Method-Status = Item-Browse:INSERT-ROW("AFTER").
END.

.
/*5*/ ON ROW-LEAVE OF BROWSE Item-Browse DO:
IF Item-Browse:NEW-ROW IN FRAME Frame1 THEN DO:
CREATE Item.
ASSIGN Item-Num = NEXT-VALUE(next-item-num)
/*6*/ INPUT BROWSE Item-Browse Item-Name Price On-hand
Cat-Description.
/*7*/ Method-Status = Item-Browse:CREATE-RESULT-LIST-ENTRY().
/*8*/ DISPLAY Item-Num WITH BROWSE Item-Browse.
END.
END.
ON CHOOSE OF btn-Delete DO:
GET CURRENT Item-Query EXCLUSIVE-LOCK NO-WAIT.
/*9*/ DELETE Item.
Method-Status = Item-Browse:DELETE-SELECTED-ROWS().
END.
/********** MAIN LOGIC **********/
OPEN QUERY Item-Query FOR EACH Item NO-LOCK.
ENABLE ALL WITH FRAME Frame1.
WAIT-FOR CHOOSE OF btn-Exit.
CLOSE QUERY Item-Query.