Negation Comparision expression not working in Lite-C?!?!?

Posted By: Ericmor

Negation Comparision expression not working in Lite-C?!?!? - 05/13/11 04:15

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.
Posted By: DJBMASTER

Re: Negation Comparision expression not working in Lite-C?!?!? - 05/13/11 04:52

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.
Posted By: Spirit

Re: Negation Comparision expression not working in Lite-C?!?!? - 05/13/11 07:11

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.
Posted By: Ericmor

Re: Negation Comparision expression not working in Lite-C?!?!? - 05/13/11 18:31

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.
Posted By: JibbSmart

Re: Negation Comparision expression not working in Lite-C?!?!? - 05/13/11 19:06

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
© 2024 lite-C Forums