Consultor Eletrônico



Kbase P38022: How to determine from outside the running program; on CTRL-F
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   8/26/2003
Status: Unverified

GOAL:

How to determine from outside the running program; on CTRL-F; whether the record of the last FIND is an existing record or one that has just been created without explicitly passing any parameters to the external monitoring procedure?

FIX:

Use a session FIND trigger on the table involved and a persistent procedure. The code below points to a possible solution direction:

/*main.p */
DEFINE VARIABLE c AS CHARACTER NO-UNDO.
DEFINE VARIABLE h AS HANDLE NO-UNDO.

IF NOT valid-handle(h) THEN run ExternalMonitor.p persistent set h.

ON CTRL-F ANYWHERE DO:
RUN getRecordState IN h.
end.


CREATE Customer.
FIND CURRENT customer NO-LOCK .
UPDATE c.
RELEASE customer.


FIND LAST customer NO-LOCK.
UPDATE c.
RELEASE customer.
/********************************************/
/************ ExternalMonitor.p ***********/
DEFINE VARIABLE rLastFound AS RECID NO-UNDO.
DEFINE VARIABLE RecordState AS CHARACTER NO-UNDO.

ON FIND OF Customer DO:
rLastFound = RECID(Customer).
END.


PROCEDURE getRecordState:
IF rLastFound = ? THEN
RecordState = "Newly Created record!".
ELSE
RecordState = "Old Record!".
MESSAGE RecordState
VIEW-AS ALERT-BOX INFO BUTTONS OK.
rLastFound = ?.
end.
/******************/