Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,574 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
What??? #298707
11/17/09 03:54
11/17/09 03:54
Joined: Nov 2008
Posts: 109
J
JGGamer Offline OP
Member
JGGamer  Offline OP
Member
J

Joined: Nov 2008
Posts: 109
I was using this code:
Code:
function nameRec()
{
	if (nameNum == 0 && myName == "Jim") {//do something;}
}



which returns this error:
machine code generator.can not translate EQ:POINTER:ARRAY:LONG.

I thought, "strange..."

I tried:
Code:
function nameRec(STRING* myName)
{
	if (nameNum == 0 && myName == "Jim") {//do something;}
}



No error, but using watch to debug, I notice that myName doesn't return a value.

Again I thought this was strange, but I wasn't about to let this slow me down, so I decided to change the string to a variable, and use numbers to represent letters.
Like myName = 100913;

It worked! I thought to myself, "I don't got brains for nothing."

So now I test this code:
Code:
randomize();
	setName = integer(random(3));
	if (setName <= 1) {myName = 100913;} //Jim
	else if (setName = 2) {myName = 190113;} //Sam
	else if (setName = 3) {myName = 020514;} //Ben



It Worked! "Cool", I thought.
So now I put in about 30 names, and set the random to 30.
Run... myName returns 0.000 every time, even though setName changes.
I reduced the number of names. Same result.

Is there a bug in this program?
Is lite-c extremely sensitive and particular?
Can someone fill me in on what is wrong with my codes please?


Re: What??? [Re: JGGamer] #298709
11/17/09 05:13
11/17/09 05:13
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
"setName = AnyNumberHere" is your error. This is an assignment. What you wanted to do instead is a comparison like in "else if (setName == 2) {/*Whatever*/}". Please note the double "=".

"setName = 2;" is an expression that evaluates to 2 and therefore is always true.


Always learn from history, to be sure you make the same mistakes again...
Re: What??? [Re: Uhrwerk] #298718
11/17/09 08:05
11/17/09 08:05
Joined: Aug 2000
Posts: 1,140
Baunatal, Germany
Tobias Offline

Moderator
Tobias  Offline

Moderator

Joined: Aug 2000
Posts: 1,140
Baunatal, Germany
And on the opposite end, "myName == "Jim"" is always false.

Re: What??? [Re: Tobias] #298722
11/17/09 08:23
11/17/09 08:23
Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
and you do not compare strings this way, myName is a pointer Jim is string itself.

str_cmp(myName,"Jim"); would be the way you are comparing them.


3333333333
Re: What??? [Re: Quad] #298852
11/18/09 13:49
11/18/09 13:49
Joined: Nov 2008
Posts: 109
J
JGGamer Offline OP
Member
JGGamer  Offline OP
Member
J

Joined: Nov 2008
Posts: 109
Thanks all. I just realized my mistake. Thanks


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