Gamestudio Links
Zorro Links
Newest Posts
ZorroGPT
by TipmyPip. 04/25/26 16:09
Z9 getting Error 058
by jcl. 04/24/26 17:48
Stooq now requires an API key
by jcl. 04/13/26 09:42
Strange "Alien" Skull created with >Knubber<
by NeoDumont. 04/10/26 18:58
400 free seamless texture pack downl. here !
by NeoDumont. 04/08/26 19:55
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
2 registered members (Grant, TipmyPip), 3,403 guests, and 11 spiders.
Key: Admin, Global Mod, Mod
Newest Members
valino, juergenwue, VladMak, Geir, ondrej
19209 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