How to access UD functions defined in a session super procedure ?

Jvb

New Member
I have defined a UD function in a .p which will be SESSION supered.

I can't seem to find the correct way to access that super implementation from another .p.

Maybe some code snippets will tell more :

PGM a.p: (which defines the function)

FUNCTION test returns CHAR (input p_something as char).

...

END.


PGM b.p : which will load a.p persistent and make it a session super.

...

RUN a.p persistent set w_handle.
SESSION:add-super-procedure(w_handle).

...

PGM c.p : a proc which wants to use the function test implemented in the session super proc.

...

What do I code here ??

Something like :

FUNCTION test returns CHAR (input p_something as char) in SUPER.

does not seems to work, as the function test is not recognised in the c.p code.


What I am doing wrong here ?

Thanks !



Jurgen van Bouchaute.
 
you need to define the function in any procedure its going to be used in.
the key bit is
def function xyx as log () in HANDLE so it knows where to find it
Personnally i dont use supers, just use a persistent library and

define the functions i it in an include file
like this
/* Load up the passed in library {&LibraryName}*/
def var zh{&LibraryName} as handle no-undo.
&global-define zh{&LibraryName} zh{&LibraryName}
procedure load{&LibraryName}:
zh{&LibraryName} = session:first-procedure.
do while zh{&LibraryName} <> ?:
if zh{&LibraryName}:private-data = "LIBRARY-{&LibraryName}" then leave.
zh{&LibraryName} = zh{&LibraryName}:next-sibling.
end.
if zh{&LibraryName} = ? then do:
run {&core}{&lib}zen-{&LibraryName}.p persistent set zh&LibraryName}.
zh{&LibraryName}:private-data = "LIBRARY-{&LibraryName}".
end.
end procedure.
run load{&LibraryName}.
/* define functions in it */
{{&core}{&lib}zfunc-{&LibraryName}.i}

core and lib are just directories
zfunc-{&LibraryName}.i
contains lines like
Function Createappserver returns handle (ConnectString As char) in {&zhlibrary}.
 
Jvb said:
I have defined a UD function in a .p which will be SESSION supered.

I can't seem to find the correct way to access that super implementation from another .p.

Maybe some code snippets will tell more :

PGM a.p: (which defines the function)

FUNCTION test returns CHAR (input p_something as char).

...

END.


PGM b.p : which will load a.p persistent and make it a session super.

...

RUN a.p persistent set w_handle.
SESSION:add-super-procedure(w_handle).

...

PGM c.p : a proc which wants to use the function test implemented in the session super proc.

...

What do I code here ??

Something like :

FUNCTION test returns CHAR (input p_something as char) in SUPER.

does not seems to work, as the function test is not recognised in the c.p code.


What I am doing wrong here ?

Thanks !



Jurgen van Bouchaute.
Hopefully you've long since figured out how to call your function. The persistent procedure route is a pain, use SUPERS like you're doing. It looks like you close, all you should have to do to call your function from the SUPER is:
DEFINE VARIABLE cCHAR AS CHARACTER NO-UNDO.
ASSIGN cChar = DYNAMIC-FUNCTION("test",INPUT blah).

Alternatetively, you could forward define your SUPER function(s) like the UIB does and put the forward defines in an include file, then you code would look something like:
DEFINE VARIABLE cCHAR AS CHARACTER NO-UNDO.
ASSIGN cChar = test(INPUT blah).

Hope this helps...
 
Back
Top