IonicWind Software

IWBasic => General Questions => Topic started by: Brian on June 08, 2011, 08:35:19 AM

Title: IF... question
Post by: Brian on June 08, 2011, 08:35:19 AM
Hi,

I keep seeing the statement (something like):
IF variable
do something...
ENDIF

Rather than (as I would do):
IF variable=1 (or whatever)
do something...
ENDIF

Could someone explain the logic of this, please?

Brian
Title: Re: IF... question
Post by: LarryMc on June 08, 2011, 08:49:22 AM
The way I understand it is the IF variable statement (without the = sign) is asking if the variable is some non-zero value.

when you have IF a =1 that will only be true for when a is = to 1.
when you have If a is true for any value except zero

Sapero has the source code for the parser; if I'm wrong he can tell us exactly how it works.

LarryMc
Title: Re: IF... question
Post by: Bruce Peaslee on June 08, 2011, 09:59:20 AM
I only use that form for Boolean variables. Some folks use it to detect zero which I think can be confusing.
Title: Re: IF... question
Post by: Brian on June 08, 2011, 10:02:25 AM
Hello,

That's great - so if I think the variable should be something other than zero,
I can just use the short form of IF

Many thanks for clearing that one up,

Brian