` Calling procedures by reference or address (Jim Kane) - Icetips Article
Icetips - Templates, Tools & Utilities for Clarion Developers

Templates, Tools and Utilities
for Clarion Developers

Icetips Article

Back to article list   Search Articles     Add Comment     Printer friendly     Direct link  

Windows API: Calling procedures by reference or address
2003-12-01 -- Jim Kane
 
Newsgroups: softvelocity.clarion.language The way I do it is like this: Map MethodIWantToClassStatic procedure(long lpMyClass,Long Parameter1),pascal someprocedure(long lpStatic, long lpClass) End Class MyClassType, Type init procedure() kill procedure() MethodIWantToCall(long parameter1) end MyClass MyClasstype code someprocedure(address(MethodIwanttoClassStatic), address(myClass)) someprocedure procedure(long lpStatic, long lpMyClass) code calldllcl.init('',1) calldllcl.callbyaddress(lpStatic, lpMyClass, valueof parameter1) calldllcl.kill() MethodIWantToCallStatic procedure (long lpMyClass, long parameter1) !,pascal loc:myclass &MyClassType code loc:MyClass&=(lpMyClass) loc:myClass.MethodIwanttocall(long parameter1) return I use my calldllcl from clarion mag and use lpMethodIWantToCall to call MethodIWantToCallStatic from anywhere and it either does something directly or calls the class method for me. There may be some easier way but this has been highly reliable and most of the time I dont really use the static procedure to call the class method but instead just do the work in the static procedure. Jim kane > I know how to pass the name of a procedure to another procedure so the > called procedure can call the named procedure. > > Now I need to store a pointer or reference to the named procedure so > that a different procedure in the class can use the pointer to call > the named procedure. It's not clear from the Clarion 6 language > reference manual how to do this (or if it can even be done). > > Also, it's not clear how to prototype the procedure parameter so that > the named procedure can be a method of another class. The language > reference manual indicates that a class method has an implicit first > parameter which is "self". > > Maybe an example of what I want to do will help. > > I will have a class method defined as > class(PGLF) > VarLookup PROCEDURE(*string varname),string > end > > When I initialize my report parser I will make a call something like > SRPG.SetVarCallback(PGLF.VarLookup) > The SetVarCallback procedure will have to store the pointer. > > Then in SRPG.GetField, I will make a call to the procedure via the > pointer. > > Normally I would prototype this as > > PT_ReportVarFunction FUNCTION(*string varname),STRING,TYPE > > class(SRPG) > SetVarCallback(*PT_ReportVarFunction pCallbackFunc) > end > > But the two questions I have are > > 1) How do I declare a member variable in class SRPG to store the value > from pCallbackFunc? Is this even possible? > > 2) Do I need to modify PT_ReportVarFunction to allow for a member > method from another class to be passed as in the example above? If so, > how?


Today is April 20, 2024, 1:08 am
This article has been viewed 35124 times.
Google search has resulted in 34 hits on this article since January 25, 2004.



Back to article list   Search Articles   Add Comment   Printer friendly

Login

User Name:

Password: