October 30, 2025, 05:22:10 PM

News:

IWBasic runs in Windows 11!


IF... question

Started by Brian, June 08, 2011, 08:35:19 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Brian

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

LarryMc

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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Bruce Peaslee

I only use that form for Boolean variables. Some folks use it to detect zero which I think can be confusing.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Brian

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