IIF() functionality

BlitzMax Forums/BlitzMax Programming/IIF() functionality

gman(Posted 2005) [#1]
is there an iif type functionality for BMAX? i dont see any in the manual :(


LeisureSuitLurie(Posted 2005) [#2]
IIF?


gman(Posted 2005) [#3]
my lingo may be a bit off :) its a type of IF statement that returns one of 2 values based on an expression:

z=(x>y ? 5 : 4)

in the example above, if x were greater than y, 5 would be returned, else 4. now the above could be rewritten to:

If x>y Then z=5 Else z=4

but the cool thing about the IIF is that it acts as a function instead of a statement and thus can be used in combination with statements.


Bot Builder(Posted 2005) [#4]
Use this if you like:

Function IIF:Object(condition, result1:Object, result2:Object)
If condition Then Return result1 else Return result2
End Function

This will be slower than just doing an if then, and also you will in many cases need to cast the result, but hey.


gman(Posted 2005) [#5]
thx bot. will give it a try.


LeisureSuitLurie(Posted 2005) [#6]
I thought he wanted to load Amiga pictures...


MrCredo(Posted 2005) [#7]
ah... i think amiga images are IFF


LeisureSuitLurie(Posted 2005) [#8]
I know. But I never assume people spell things correctly.


xlsior(Posted 2005) [#9]
ah... i think amiga images are IFF


Actually, like .AVI's, .IFF are just a container format and can be anything. IFF is short for Interchange File Format

Most common Amige images are IFF-ILBM (compressed images)

But you'll also have:
IFF-ACBM (uncompressed images)
IFF-SMUS (tracked music)
IFF-8SVX (wave files)
And at least a dozen or so other subformats, for storing anything from word processor data to sound and images.

'IFF' isn't automatically an image file.


Neochrome(Posted 2005) [#10]
IFF = interchangable file format