Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, 1 invisible), 1,203 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 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,210
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
İ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 | 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