Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (Aku_Aku, 7th_zorro, Ayumi), 1,050 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Negation Comparision expression not working in Lite-C?!?!? #370405
05/13/11 04:15
05/13/11 04:15
Joined: Apr 2007
Posts: 125
Brazil - São Paulo
Ericmor Offline OP
Member
Ericmor  Offline OP
Member

Joined: Apr 2007
Posts: 125
Brazil - São Paulo
I´m translating a large old .wdl project to Lite-C.
I´ve received the following error in my last attempt:

Error in ´actions.c´ line 763:
syntax error
< if!(player_A.frame>=91&&player_A.frame<=97)||player_A.frame<=90&&onfloor==0)
>

After some struggle, i noticed that the engine would accept the expression if i removed the "!" negation comparision symbol from it.
Just to be sure, i found the following example on the manual:

Code:
!((10 <= x) && (15 => x)) // true if x is less than 10 or greater than 15 (lite-C only)



Then, i added it to my code, just replacing the 'x' for 'my.x'...

Code:
if !((10 <= my.x) && (15 => my.x)) {wait(1);}



...wich generates the following error:

Error in 'actions.c' line 763:
syntax error
< if !((10<=my.x) && (15=>my.x)) {wait(1);}

>

If a code from the MANUAL, wich is specifically meant to be used in Lite-C, is generating errors, i could only guess that´s a manual mistake.
I was unable to find any correct syntax for the expression so far anywhere in the manual... please help.
Thanks in advance.

Re: Negation Comparision expression not working in Lite-C?!?!? [Re: Ericmor] #370406
05/13/11 04:52
05/13/11 04:52
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
Hey again :D, you have to move the ! operator inside the if(..) clause...

if (!((10 <= my.x) && (15 => my.x))) {wait(1);}

The ! operator has higher precedence than the && operator, so we enclose the inner statement in parenthesis ( ) and then negate the whole expression.

Re: Negation Comparision expression not working in Lite-C?!?!? [Re: DJBMASTER] #370413
05/13/11 07:11
05/13/11 07:11
Joined: Sep 2003
Posts: 929
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 929
You seem to have often problems with your project translation, this could be because of not knowing the lite-C syntax. For transferring a large WDL script to C, you should know the syntax or else the translating wont be much fun. The Sam's Learning C in 21 days tutorial is very good.

Re: Negation Comparision expression not working in Lite-C?!?!? [Re: DJBMASTER] #370524
05/13/11 18:31
05/13/11 18:31
Joined: Apr 2007
Posts: 125
Brazil - São Paulo
Ericmor Offline OP
Member
Ericmor  Offline OP
Member

Joined: Apr 2007
Posts: 125
Brazil - São Paulo
This topic shouldn´t have been moved.
The WRONG EXAMPLE IS IN THE MANUAL.
Did you read me post without paying attention?
I´ve tried a CODE SAMPLE FROM THE MANUAL, and this code sample IS WRONG, IS OUTDATED, IS NON-WORKING.
I thank you for the help with the correct syntax, but please, FIX THE MANUAL.

Re: Negation Comparision expression not working in Lite-C?!?!? [Re: Ericmor] #370525
05/13/11 19:06
05/13/11 19:06
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
The manual is correct. You took it out of context.

Note the first example:
Code:
10 < x

But if you tried:
Code:
if 10 < x

...you'd get an error because you always need parentheses around the comparison in an "if".

The manual says "if (comparison)" -- the comparison is always inside parentheses. Further sets of parentheses can be used to control precedence, but a comparison must reside in a pair of parentheses.

Jibb


Formerly known as JulzMighty.
I made KarBOOM!

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