Actions based on Events

Hi everybody,

I am using Progress 10.0B,
consider the following code,
*********************************************************
FIND FIRST ITEM WHERE ITEM.item-num = 5.

UPDATE ITEM.item-Num SKIP(1)
ITEM.item-Name SKIP(1)
ITEM.price SKIP(1)
WITH FRAME f SIDE-LABELS.
*********************************************************

It shows a record which can be updated and if the cursor is placed in last box and presses enter it gets updated...

I want to know if we can write our own event for this On press of ENTER key something should happen, can it be written explicitly????
So that if i press someone presses enter when they are in first field also the value should get updated...

Plzzz help me out... :confused:

Thank u in advance.
 
Hi,
Hav got something like this...
But it is for only item-name, i need it common across all fields...
Do we have something like that,
********************************************************
ON RETURN OF ITEM.item-name
DO:
MESSAGE "Hi!!"
VIEW-AS ALERT-BOX INFO BUTTONS OK.
END.
********************************************************
 
Thank u...

I know to use on return, but we can use it only for checking text value. I need to write only one procedure or trigger for "ENTER". Whereever user presses ENTER, this set of code should get executed.

On press of ENTER, i need something like this in common...
 
Hi,

If you want that when user presses 'Enter' a set of code should execute.

Try

On 'enter' anywhere do:
end.

If you want it in a program then write it there.
If you want it in an application (common for all the programs, like F1 for help) then write it in an program that runs persistent and call it when application starts.

-Parul.
 
Do you mean some code that runs whenever you press ENTER in a frame that automatically assigns the variable you are entering and moves on to the next variable?

You'd want something like this (untested and off the top of my head so don't blame me if it doesn't compile):

on return anywhere run p_enter (self:handle).

procedure p_enter:
def input param inp_handle as widget-handle no-undo.

if not valid-handle (inp_handle) then return.

/* To assign the values */
case inp_handle:name:
when "item-Num" then assign item.item-num in frame f.
when "item-name" then assign item.item-name in frame f.
when "price" then assign item.price in frame f.
end case.

/* To move the position */
case inp_handle:name:
when "item-Num" then apply "ENTER" to item.item-name in frame f.
when "item-name" then apply "ENTER" to item.price in frame f.
end case.

/*
You can enable/disable fields and use the APPLY "TAB" to move between fields if you want.

In fact, because you are passing a handle to the procedure, you can use this to control the behaviour of any field/variable in any frame in your program. It's a bit tidier than having loads of ON ENTER commands and is fairly easy to read.
*/

end procedure.
 
Hi,

I can understand the code, but it doesnt get compiled Mr.Sphipp, i have something like this (let we consider a simple example), i dont get answer for this. It gets compiled, executed but doesn't pop-up msg when i press ENTER or RETURN from that box.

********************************************************
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE j AS INTEGER NO-UNDO.
SET i j.

ON RETURN ANYWHERE
MESSAGE i
VIEW-AS ALERT-BOX INFO BUTTONS OK.
********************************************************

Also as per Mr.Parul's idea i tried out but all in-vain. It is not working,

*******************************************************
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE j AS INTEGER NO-UNDO.
SET i j.
ON 'ENTER' ANYWHERE
MESSAGE i
VIEW-AS ALERT-BOX INFO BUTTONS OK.
*******************************************************

Can anyone help me out???????:confused:
 
Hi,

I can understand the code, but it doesnt get compiled Mr.Sphipp, i have something like this (let we consider a simple example), i dont get answer for this. It gets compiled, executed but doesn't pop-up msg when i press ENTER or RETURN from that box.

********************************************************
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE j AS INTEGER NO-UNDO.
SET i j.

ON RETURN ANYWHERE
MESSAGE i
VIEW-AS ALERT-BOX INFO BUTTONS OK.
********************************************************

Also as per Mr.Parul's idea i tried out but all in-vain. It is not working,

*******************************************************
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE j AS INTEGER NO-UNDO.
SET i j.
ON 'ENTER' ANYWHERE
MESSAGE i
VIEW-AS ALERT-BOX INFO BUTTONS OK.
*******************************************************

Can anyone help me out???????:confused:


Hi,

In your sample the trigger code is never executed because the SET statements executes before the trigger. So there is simply no way that PROGRESS knows about any trigger. When you write a program make sure that the triggers are defined before any input blocking statement like SET, UPDATE, WAIT-FOR etc....

The next sample should work for you :

Code:
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE j AS INTEGER NO-UNDO.
 
DEFINE FRAME a
    i AT 2
    j AT 2.
 
ON 'ENTER' ANYWHERE 
DO:
    DO WITH FRAME a:
        
        MESSAGE SELF:INPUT-VALUE
        VIEW-AS ALERT-BOX INFO BUTTONS OK.
    END.
END.
 
SET i j WITH FRAME a.

Actually it is more common practice to use ENABLE and WAIT-FOR instead of SET. You might want to replace the SET statement with the next lines of code.

Code:
ENABLE ALL WITH FRAME a.
IF NOT THIS-PROCEDURE:PERSISTENT THEN WAIT-FOR CLOSE OF THIS-PROCEDURE.
 
Back
Top