Author Topic: Logic syntax  (Read 1458 times)

0 Members and 1 Guest are viewing this topic.

Randy

  • Guest
Logic syntax
« on: April 22, 2002, 09:37:42 AM »
Is it possible to string three or more items in an "if" statement that use the "&&" ?

I get errors when I do something like this:
 if (v101==1 && v102==1 && v103==1) {

whereas if I did the same thing with "||" it worked
 if (v101==1 || v102==1 || v103==1) {


However, I need the results of using the "&&" so I resorted to a solution like this:
 if (v101==1 && v102==1) {
   if (v103==1) {
     //code
   }
 }


Is this a severe limitation of AGI or am I miscoding something?



Offline Joel

Re:Logic syntax
« Reply #1 on: April 22, 2002, 10:08:05 AM »
If my understanding of the AGI Specs is correct (and it better be, since I'm coding something that generates compiled code), then it should be perfectly legal to say:

if (v100 == 2 && v101 == 3 && v102 == 4)

In fact, I just tested that very if-statement in AGI Studio (v.1.35) and it compiled without complaints. I assume that's what you mean when you say you get errors -- compile errors? If that's the case, then the error must be a different problem.

Randy

  • Guest
Re:Logic syntax
« Reply #2 on: April 22, 2002, 11:35:39 AM »
yup, compile errors. It would not let me compile, yet it would let me compile the identical "or" statement. I don't have the computer I used for this project in front of me so I can't tell you the exact error message, I can check that out tonight though.

Hmm... weird.

Offline Joel

Re:Logic syntax
« Reply #3 on: April 22, 2002, 03:13:25 PM »
make sure that you didn't type something to the effect of

if (v1 == 1 && v2 == 2 && v3 = 3)

because that is a syntax error. You can't have v3 = 3 inside an if-statement in AGI (although you can in C) -- the compiler will say "expression syntax error" or something like that. Aside from that, I can't tell you more with what I know right now. The code you're trying to write compiles even in AGI Studio 1.31 (Peter Kelly's last release).

Offline Nick Sonneveld

Re:Logic syntax
« Reply #4 on: April 22, 2002, 07:08:31 PM »
check your spaces and make sure none are tabs.. the compiler might not like them.  The error msg would be helpful though.

- Nick
Nick Sonneveld  |  AGI Dev  |  NAGI


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.059 seconds with 21 queries.