Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AemStones, AndrewAMD, gamers, Kingware), 1,679 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19054 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Get function pointer #153257
09/10/07 16:03
09/10/07 16:03
Joined: Jul 2006
Posts: 150
Deutschland/Germany, nahe Hamb...
dennis Offline OP
Member
dennis  Offline OP
Member

Joined: Jul 2006
Posts: 150
Deutschland/Germany, nahe Hamb...
Hi!

How can I get a pointer to a function using a string which contains the name of the function?

I thought of something like that....

Code:
STRING* NameOfFunction = "Test_Fun";
voidptr = ????(NameOfFunction);



Re: Get function pointer [Re: dennis] #153258
09/10/07 20:38
09/10/07 20:38
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
You can use engine_getvar here.


Always learn from history, to be sure you make the same mistakes again...
Re: Get function pointer [Re: Uhrwerk] #153259
09/11/07 11:30
09/11/07 11:30
Joined: Jul 2006
Posts: 150
Deutschland/Germany, nahe Hamb...
dennis Offline OP
Member
dennis  Offline OP
Member

Joined: Jul 2006
Posts: 150
Deutschland/Germany, nahe Hamb...
I tried that:

Code:
 
#include <acknex.h>
#include <default.c>

function Test_Fun()
{
wait(-10);
sys_exit("");
}

STRING* NameOfFunction = "Test_Fun";

void* voidptr()
{

wait(1);

}

long type;

function main()
{

wait(1);

voidptr = engine_getvar(NameOfFunction,type);

voidptr();

}



It did not work...."Error E1513: Crash in main"

How can I do that correctly?

Re: Get function pointer [Re: dennis] #153260
09/11/07 12:00
09/11/07 12:00
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
http://manual.conitec.net/engine_getscript.htm

But for what reason do you need to find a function by its name? Why don't you call the function directly?

Re: Get function pointer [Re: jcl] #153261
09/11/07 12:30
09/11/07 12:30
Joined: Jul 2006
Posts: 150
Deutschland/Germany, nahe Hamb...
dennis Offline OP
Member
dennis  Offline OP
Member

Joined: Jul 2006
Posts: 150
Deutschland/Germany, nahe Hamb...

Oh yes...that works..!

I want to make a GUI-Editor and want to change the event function of a panel by user input.


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

Gamestudio download | chip programmers | 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