May 15, 2024, 12:43:24 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Dynamics

Started by Zen, November 23, 2006, 02:59:08 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Zen

A little bit advanced for here maybe but it does say "Stuck?" Well I guess its more curiosity than stuck but here goes...

If i make a class with a dozen methods. Is there a way to dynamicly call a method from that class? I ask this because Im used to doing all kinds of things like this in PHP, I know its totally different but i just wondered if it was possible?

Say for instance i have a text box and a button. Would there be a way so that when i click the button it will run the method name i tryped in the text box? Obviously no parameters involved yet. Also wouldnt this be where exception handling would come in? Incase the method didnt exist, i could imagine the program crashing at this point?

Lewis

Steven Picard

VB had something similar.  It was CallByName.  There are actually several situations where I've made good use of it.

Ionic Wind Support Team

PHP is actually an interpreter.

The names of functions in a compiler don't exist once the source code has been compiled.  It is just an address.  You can call functions indirectly by address in Aurora

COM is a different story.  If you look at the work Sapero has been doing you'll see that COM does work by using the names of interface methods. 

Paul.
Ionic Wind Support Team

Steven Picard

Quote from: Paul Turley on November 23, 2006, 09:40:40 AM
The names of functions in a compiler don't exist once the source code has been compiled.  It is just an address.  You can call functions indirectly by address in Aurora
This is why VB could call a function dynamically provided it was in a class.  It couldn't do this if it was just in a module.

Zen

Yeah I thought that was the case. Its just i find it very usefull in PHP. I know that kind of programming and actuall windows programming is totally different, I just liked the idea and used that as an example.

Anyway, i've never used COM so im not really sure what interfaces are used for or how they work. I've used interfaces in PHP but i think they are probably different. Does an interface have to be used with COM??

Lewis

Kale

you could put your procedures into a DLL and then use these WinAPI commands:

Module = LoadLibrary("Name.dll")
GetProcAddress(Module, "MyProcedure")

And then call the procedure from that address.

Zen

Yeah i thought of that. It was more calling methods dynamically than subroutines. Bearing in mind i dont have any need for this at the moment but i was wondering if it was possible or not with Aurora.

Lewis

Parker

Use the export keyword and you can do it with your exe.

Zen

Hmmm yes thats interesting actually parker. I've done that before, but I can't remember what for lol.

Lewis