RE: "if var!=-1 then" and "if not var=-1 then"
- Posted by "Elliott S. de Andrade" <quantum_analyst at hotmail.com> Feb 24, 2004
- 509 views
>From: CoJaBo <cojabo at suscom.net> >Subject: "if var!=-1 then" and "if not var=-1 then" > >It there a differance between >if var!=-1 then >and >if not var=-1 then? > Yes. They have different precedence levels. not is higher than =, so it's really doing this: if (not var) = -1 then which, if var equals -1 then it will do: (not var) = -1 (not -1) = -1 0 = -1 -> false >On a program I was working on here is what happened: > >?st--displayed 5 >if not st=-1 then >puts(1,"Hello!")--didn't run >--bunch of other stuff was here, didn't run >end if > >Then I tried this to see what would happen: > >st=-1 >?st--displayed 5 >if not st=-1 then >puts(1,"Hello!")--still didn't run >--bunch of other stuff was here,still didn't run >end if > >Then I tried this: > >?st--displayed 5 >if st!=-1 then >puts(1,"Hello!")--Displayed "Hello!" >--bunch of other stuff was here, ran fine >end if > >What is happening?!?!? >