Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IFZ, IFT, IFF ?
#1
I know fb is not xb but while working with different languages you start to appreciate the little details, like:

IFZ val
=====> if the numeric val is ZERO (regarding strings = if lenght is ZERO...)

IFT val
=====> if the numeric val is TRUE

IFF val
=====> if the numeric val is FALSE

Is it possible to get these in the future?
Thanks
Reply
#2
you can implement these using macros.
url]http://fbide.sourceforge.net/[/url]
Reply
#3
Example:
Code:
#define IFZ(n) IF n = 0
#define IFT(n) IF n <> 0
#define IFF(n) IF n = 0

IFF (3 = 3) THEN
   PRINT "If you can read this, your computer is on crack."
ELSE
   PRINT "Congratulations! Your computer is sane!"
END IF

SLEEP
END
Reply
#4
Yes, doing it with macros is one way that works for me.

But if something so 'general' is used often, these macros need to be included almost every time.

Anyhow, thanks for pointing me to this possibility.

BTW
Personally I would use:

#define IFT(n) IF n = 1

because I always use ONE for TRUE :wink:
Reply
#5
Cute.

But I think QB/FB quite disagrees with your opinions about True/False 1/0

False is 0.
True is everything else.
False is the base definition.
Hence the not-equals 0.
Reply
#6
You got a point here, but for my defense I have to say that I would not qualify as a former qb user.

Because of this I can't say if your comment is correct or not. :wink:

In every language I used to code, TRUE was always a fixed value - in my case ONE. :wink:

On a sidenote:
If my memory is not deceiving me, some languages even have -1 as TRUE, this said, I always thought it's a fixed number and not - NOT ZERO :roll:

But I could be wrong ... :-?

--------------------------------
... it would not be the first time
--------------------------------


Take care Big Grin
Reply
#7
I really just depends...

Code:
If Que = True Then Do_Something...

If Que Then Do_Something_Else..

The first one will execute only if Que is exactly equal to the value of True.

The second will execute anytime Que is <> 0.


That's how it works in QB anyway.

Wink
Reply
#8
I don't think these should be built in... it's a lot more readable to write 'if x = 0' than 'if ifz(x)' imho. Smile
Reply
#9
that would be

if x=0

vs

ifz(x)

no need for the extra if.
ttp://m0n573r.afraid.org/
Quote:quote: "<+whtiger> you... you don't know which way the earth spins?" ... see... stupidity leads to reverence, reverence to shakiness, shakiness to... the dark side
...phear
Reply
#10
TRUE is -1 in QB/VB/FB, as there is no short-circuit evaluation.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)