Reputation: 251
How Can I call the external procedure persistently to take an output value. If I call that in main block code section then its called only one time and gave one time output. Could you please help me in this case with an sample example? I am new to progress. Any help would be great.
Upvotes: 0
Views: 1607
Reputation: 14020
There may be some confusion about how to use persistent procedures. You do not call the external procedure repeatedly. You call the external procedure once with the "persistent" option in order to keep it in memory. You then call internal procedures of the persistent procedure, possibly repeatedly, in order to get stuff done.
Sort of like invoking methods of an object.
If you prefer to avoid dealing with persistent procedure handles you can have a persistent procedure install itself as a "session super-procedure". The internal procedures can then be run without referencing a specific handle. (This works well and is not confusing as long as you have unique internal procedure names and do not want to do things like "overloading".)
main.p:
/* main.p
*/
define variable i as integer no-undo.
run pp.p persistent.
do while lastkey <> asc('q'):
run random1to10( output i ).
message i.
readkey.
end.
pp.p:
/* pp.p
*/
/* Install self as a session super-procedure */
session:add-super-procedure( this-procedure ).
return.
procedure random1to10:
define output parameter x as integer no-undo.
x = random( 1, 10 ).
end.
Upvotes: 2
Reputation: 3379
main.p
DEFINE VARIABLE hp AS HANDLE NO-UNDO.
DEFINE VARIABLE cc AS CHARACTER NO-UNDO.
RUN foo.p PERSISTENT SET hp. // persistent keeps it, SET hp makes it accessible
RUN bar IN hp ( OUTPUT cc ).
DELETE OBJECT hp.
MESSAGE cc.
foo.p
PROCEDURE bar:
DEFINE OUTPUT PARAMETER cc AS CHARACTER NO-UNDO.
cc = "see sea":u.
END PROCEDURE.
https://abldojo.services.progress.com:443/#/?shareId=5d1f239e4b1a0f40c34b8bd3
Upvotes: 4