Progress
Programming
Handbook


Method Example

The following procedure assigns an editor widget to the contents of a file using the INSERT–FILE( ) method. It writes the contents back to the file using the SAVE–FILE( ) method after the user has a chance to change it. Messages are displayed depending on user’s input and the success or failure of the methods, which return TRUE if they succeed:

p-method.p
DEFINE VARIABLE To-Do AS CHARACTER VIEW-AS EDITOR SIZE 60 BY 10.
DEFINE FRAME DoFrame SPACE(3) To-Do WITH SIDE-LABELS SIZE 76 BY 12.

ON GO OF To-Do IN FRAME DoFrame DO:
    IF To-Do:SAVE-FILE("to-do.lst") THEN
        MESSAGE "TO DO list saved."
            VIEW-AS ALERT-BOX INFORMATION BUTTONS OK.
    ELSE DO:
        BELL.
        MESSAGE "TO DO list NOT saved!!" 
            VIEW-AS ALERT-BOX WARNING BUTTONS OK.
    END.
END.

ON END-ERROR OF To-Do IN FRAME DoFrame
    MESSAGE "TO DO list NOT changed." 
        VIEW-AS ALERT-BOX INFORMATION BUTTONS OK.

ENABLE ALL WITH FRAME DoFrame.

IF To-Do:INSERT-FILE("to-do.lst") THEN
    WAIT-FOR GO OF To-Do IN Frame DoFrame.
ELSE DO:
    BELL.
    MESSAGE "TO DO list NOT available." 
        VIEW-AS ALERT-BOX MESSAGE BUTTONS OK.
END. 


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