Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
3 registered members (AndrewAMD, Grant, Neb), 908 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Set String to function name #387101
11/14/11 13:06
11/14/11 13:06
Joined: Aug 2008
Posts: 394
Germany
Benni003 Offline OP
Senior Member
Benni003  Offline OP
Senior Member

Joined: Aug 2008
Posts: 394
Germany
Hey, hope anyone can help me.
I want to set a String to a name of a function.
Like this:

void f_test()
{
.......
}

function main()
{
STRING* str=str_create("");
.....
void* pFp;
pFp=f_test;

// now here must be functions to set the STRING str to the pFp name, means str="f_test". I have to get the functionsname from pFp.
}

Does anyone knows how to do it?

Last edited by Benni003; 11/14/11 13:06.
Re: Set String to function name [Re: Benni003] #387102
11/14/11 13:13
11/14/11 13:13
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Ive never used it myself, so this code for getting it into a string maybe a bit iffy.
But this is the 'best' I can think of...
Code:
function main()
{
STRING* str=str_create("");
.....
void* pFp;
pFp=f_test;

char* tmp_name;
engine_getscriptinfo(pFp, &tmp_name);
str_cpy(str, tmp_name);

}




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Set String to function name [Re: EvilSOB] #387108
11/14/11 14:04
11/14/11 14:04
Joined: Aug 2008
Posts: 394
Germany
Benni003 Offline OP
Senior Member
Benni003  Offline OP
Senior Member

Joined: Aug 2008
Posts: 394
Germany
Thank you for your help, but it's not right working.
The STRING str is not set to "f_test". It's set to any other function name. Very crazy. Maybe a bug?
Is there an other way to do it?

Last edited by Benni003; 11/14/11 15:43.
Re: Set String to function name [Re: Benni003] #387135
11/14/11 19:36
11/14/11 19:36
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
It does indeed appear to be a bug...

Try TEMPORARILY removing "#include <default.c>".

That worked for me...

[EDIT] It worked for me in ONE project, but not in others...
I would suggest log this as a BUG in the 'bug hunt' forum.


Last edited by EvilSOB; 11/14/11 20:33. Reason: Update

"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Set String to function name [Re: EvilSOB] #387140
11/14/11 21:47
11/14/11 21:47
Joined: Aug 2008
Posts: 394
Germany
Benni003 Offline OP
Senior Member
Benni003  Offline OP
Senior Member

Joined: Aug 2008
Posts: 394
Germany
I wrote it in the BUG HUNT forum. Now I'm curious what JCL will say.

Re: Set String to function name [Re: Benni003] #387457
11/18/11 21:31
11/18/11 21:31
Joined: Dec 2009
Posts: 128
China
frankjiang Offline
Member
frankjiang  Offline
Member

Joined: Dec 2009
Posts: 128
China
you can write code like this.
Code:
#define fun1 1
#define fun2 2
function yourProc(int function_name,char* _par)
{
	switch(function_name)
	{
        case 	fun1:
            do something you want...
            break;
        case fun2:
            ...
            break;
	}
}




Last edited by frankjiang; 11/18/11 21:33.

development 3d game is interesting!

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