PxPlus User Forum
Main Board => Discussions => Programming => Topic started by: Jeffrey Ferreira on February 25, 2019, 11:51:13 AM
-
Hello List,
I'm trying to avoid using a global function but I would like function available in multiple programs. I tried doing the following:
PROG01
10 perform "PR0G02;DEFINE_FUNCTIONS"
20 PRINT fnPAIR$("Key","Value")
but I can't access the function defined in PR0G02
is my only recourse a Global Function?
jeff
-
You could look into XEQ as a possibility:
https://manual.pvxplus.com/PXPLUS/functions/xeq.htm (https://manual.pvxplus.com/PXPLUS/functions/xeq.htm)
-
This looks promising James. I will give it a try. Thank you.
-
Hi Jeff,
You could make it an object with the functions defined as methods and call it something like myUtilities.
DEF CLASS "myUtilities"
FUNCTION pair$(key$, value$)pair
END DEF
pair:
ENTER key$, value$
...
return result$
Then in programs you want to use it you do a myUtilies=NEW("myUtilties"). Then you simply call the functions like myUtilities'pair$("Key","Value")
-
Simply make your function global by the inclusion of the % in the function name as in:
DEF FN%PAIR$(local a$, local b$)
....
END DEF
-or-
DEF FN%PAIR$(local a$, local b$)=A$+"="+quo+b$+quo
See the description on "Global User-defined Functions" at the bottom of this page:
https://manual.pvxplus.com/page/PxPlus%20User%20Guide/Programming%20Constructs/Called%20Procedures/Overview.htm