Is there some command in GLBasic similar to the Inline If provided in VB - IIF ?
Public Function IIf( _
ByVal Expression As Boolean, _
ByVal TruePart As Object, _
ByVal FalsePart As Object _
) As Object
It allows you to conditionally return 1 or other value inline.
IIF(var=1,1,0) // If var equals one then substitute 1 here, otherwise substitute 0 here.
What I am trying to do is render a sprite that does conditional vertex blending.
STARTPOLY 0,0 // Bitmap = No.0
POLYVECTOR x, y, txt_spr.tx1, txt_spr.ty1, IIF(BLEND=1, RGB(R,G,B), RGB(255,255,255))
POLYVECTOR x, y+height, txt_spr.tx1, txt_spr.ty2, IIF(BLEND=2 RGB(R,G,B), RGB(255,255,255))
POLYVECTOR x+width, y+height, txt_spr.tx2, txt_spr.ty2, IIF(BLEND=3, RGB(R,G,B), RGB(255,255,255))
POLYVECTOR x+width, y, txt_spr.tx2, txt_spr.ty1, IIF(BLEND=4, RGB(R,G,B), RGB(255,255,255))
ENDPOLY
There are several ways to do this, in your case I would think about this:
FUNCTION IIF: condition, if_true, if_false
IF condition
RETURN if_true
ELSE
RETURN if_false
ENDIF
ENDFUNCTION
Not tested, but it should perfect fit your needs...
Yes; I understand it is easy enough. If there is something that already exists I prefer to use it.
I think nothing like that exists right now, although it's a useful function to have for typing clean code.
ah. IIF is that command? I didn't know about it.
In C it's
expression ? true_value : false_value
I'll put that on the list.
Yes IIF is common enough basic version of C's "expression ? true_value : false_value"