Gamestudio Links
Zorro Links
Newest Posts
Zorro version 3.0 prerelease!
by TipmyPip. 02/24/26 08:49
ZorroGPT
by TipmyPip. 02/23/26 21:52
WFO Training with parallel cores Zorro64
by Martin_HH. 02/23/26 15:29
Camera always moves upwards?
by clonman. 02/21/26 09:29
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 02/19/26 13:22
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
5 registered members (Martin_HH, AndrewAMD, TipmyPip, qin, VoroneTZ), 5,300 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
alx, ApprenticeInMuc, PatrickH90, USER0328, Sfrdragon
19199 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Can I call a function whose name is stored in a variable ??? #215629
07/12/08 14:06
07/12/08 14:06
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Hi everybody,

I got a question about calling functions.

Is it possible to call a function when I have the function name only stored in a variable?

For example:

action test() {
// do somethins
}

STRING* functionName = "test";

void main() {
// call action with name functionName
}

Regards,
Pegamode.

Re: Can I call a function whose name is stored in a variable ??? [Re: pegamode] #215630
07/12/08 14:20
07/12/08 14:20
Joined: Jan 2007
Posts: 221
F
Fenriswolf Offline
Member
Fenriswolf  Offline
Member
F

Joined: Jan 2007
Posts: 221
Hello,

perhaps this is of any help:
http://www.conitec.net/beta/engine_getscript.htm

Re: Can I call a function whose name is stored in a variable ??? [Re: Fenriswolf] #215632
07/12/08 14:27
07/12/08 14:27
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Hey ... that seems to be exactly what I am looking for.

I'll try that and give feedback.

Thanks.

Re: Can I call a function whose name is stored in a variable ??? [Re: pegamode] #215633
07/12/08 14:39
07/12/08 14:39
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Hi,

when I call:

pFunction = engine_getscript("myFunction");
pFunction();

everything works fine, but when I do something like that:

STRING* funcName = "myFunction";
...
pFunction = engine_getscript(funcName);
pFunction();

the engine crashes :-(

Any ideas ???

Regards,
Pegamode.

Re: Can I call a function whose name is stored in a variable ??? [Re: pegamode] #215634
07/12/08 14:44
07/12/08 14:44
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Ahhhhhhhhhh ...

I have to put the function name in a char and not in a string.

Now everything works fine.

Thanks for your help.

Regards,
Pegamode.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1