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
2 registered members (Quad, AndrewAMD), 1,007 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
wrong number/types of parameter #276464
07/05/09 07:50
07/05/09 07:50
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,

I use the following code:

Code:
void ediag(STRING* fctName, STRING* level, STRING* diagStr) {
	...
}

void ediag(STRING* fctName, STRING* diagStr) {
	ediag(fctName, LEVEL_INFO, diagStr);
}

void ediag(STRING* diagStr) {
	ediag(NULL, NULL, diagStr);
}



This call works fine:

STRING* LEVEL_INFO = "INFO ";
STRING* fctName = "test";

ediag(fctName, LEVEL_INFO, "huhu");

But this gives me "wrong number/types of parameter":

ediag(fctName, "huhu");

But this works:

ediag(fctName, str_create("huhu"));

The same with:

ediag("huhu");

isn't working, but

ediag(str_create("huhu"));

works fine.

Can someone help (or tell) me why I don't need str_create in the first case, but in all others?

Regards,
Pegamode.

Re: wrong number/types of parameter [Re: pegamode] #276473
07/05/09 09:33
07/05/09 09:33
Joined: Feb 2009
Posts: 84
Deutschland/Niedersachsen
GorNaKosh Offline
Junior Member
GorNaKosh  Offline
Junior Member

Joined: Feb 2009
Posts: 84
Deutschland/Niedersachsen
You need the str_create function to create a string. And only a string is the correct type which have to be passed to the function. If you want to use your functions the other way, you have to change the type from STRING into char
Code:
void ediag(char* diagStr) {
	//your code
}

ediag("huhu");



Last edited by GorNaKosh; 07/05/09 09:33.
Re: wrong number/types of parameter [Re: GorNaKosh] #276482
07/05/09 10:56
07/05/09 10:56
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
But then the line:

ediag(fctName, LEVEL_INFO, "huhu");

should not work either, but it works fine.

By the way those lines are also correct (from the tutorial):

STRING* player_str = "Johnny Bravo";
STRING* test_string = ""; // empty string
STRING* riddle = "#100"; // string which stores up to 100 characters

Re: wrong number/types of parameter [Re: pegamode] #276531
07/05/09 14:49
07/05/09 14:49
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Passing string to functions is still something of a black art.
(Sell your soul to the devil and it gets EASIER)

Try changing your function calls to use the builtin _str() function like so,
ediag(fctName, _str("huhu")); and it should sort the problem out.

In THEORY, ediag(fctName, "huhu"); shouldnt ever work, but something
in the way 3DGS does its "automatic" conversion of String to char and vise-versa
doesnt always work right, or doesnt always work wrong, depending on your point of view.
Throw overloaded functions into the mix and it just gets worse.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: wrong number/types of parameter [Re: EvilSOB] #276612
07/05/09 19:09
07/05/09 19:09
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Ok, that's what I thought.
Maybe JCL can correct it some day :-)

Regards,
Pegamode.


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