I have the doubt regarding proc-handle and handle where we a

Posted by ravinandhan on 19-Jan-2015 00:21

procedure persistent.p


DEFINE VARIABLE hproc AS HANDLE NO-UNDO.
DEFINE VARIABLE v_name AS CHARACTER NO-UNDO.
MESSAGE "a"
VIEW-AS ALERT-BOX INFO BUTTONS OK.
RUN a.p PERSISTENT SET hproc.
MESSAGE "b"
VIEW-AS ALERT-BOX INFO BUTTONS OK.

RUN a.p PERSISTENT SET proc-handle ( INPUT "muthukrishnan",OUTPUT v_name ).
/*RUN mesg IN hproc = proc-handle
(INPUT "muthukrishnan",OUTPUT v_name).*/
MESSAGE "c"
VIEW-AS ALERT-BOX INFO BUTTONS OK.
MESSAGE v_name
VIEW-AS ALERT-BOX INFO BUTTONS OK.

procedure a.p

DEFINE VARIABLE a AS INTEGER NO-UNDO.
ASSIGN a =10.
RUN pp(INPUT-OUTPUT a).
DISP a.
PROCEDURE pp:
DEFINE INPUT-OUTPUT PARAMETER a AS INTEGER.
ASSIGN a =a + 20.
DISP a.
END PROCEDURE.
PROCEDURE mesg:
DEFINE INPUT PARAMETER p_name AS CHARACTER NO-UNDO.
DEFINE OUTPUT PARAMETER p_name_detail as CHARACTER.
ASSIGN p_name_detail = "my name is" + p_name.
END PROCEDURE.

can any one explain how to execute this with example.

Posted by James Palmer on 19-Jan-2015 02:34

Ignoring the fact this is the wrong forum (Maybe [mention:f822c6bf04534292b3fe04704ddd8dd6:e9ed411860ed4f2ba0265705b8793d05] can move it?), Run Persistent loads the whole procedure into memory and will only run the contents of the MAIN-BLOCK. You then have the internal procedures and functions available to run in the hproc handle.

The line that is wrong here is "RUN a.p PERSISTENT SET proc-handle ( INPUT "muthukrishnan",OUTPUT v_name )." but it is redundant. Remove it. The commented lines below it are almost right and should be

RUN mesg IN hproc

(INPUT "muthukrishnan",OUTPUT v_name).

That should set you right.

At the end of persistent.p you should be clearing up your handles and removing a.p from the persistent stack, otherwise you will get memory leaks and eventually crashes.

All Replies

Posted by James Palmer on 19-Jan-2015 02:34

Ignoring the fact this is the wrong forum (Maybe [mention:f822c6bf04534292b3fe04704ddd8dd6:e9ed411860ed4f2ba0265705b8793d05] can move it?), Run Persistent loads the whole procedure into memory and will only run the contents of the MAIN-BLOCK. You then have the internal procedures and functions available to run in the hproc handle.

The line that is wrong here is "RUN a.p PERSISTENT SET proc-handle ( INPUT "muthukrishnan",OUTPUT v_name )." but it is redundant. Remove it. The commented lines below it are almost right and should be

RUN mesg IN hproc

(INPUT "muthukrishnan",OUTPUT v_name).

That should set you right.

At the end of persistent.p you should be clearing up your handles and removing a.p from the persistent stack, otherwise you will get memory leaks and eventually crashes.

This thread is closed