Revision history for KeyPgIif


Revision [26614]

Last edited on 2023-06-30 01:14:27 by fxm [completed description]
Additions:
**Note:** If the condition evaluation can be done at compile time (if the comparison expression is a constant), the usage rules are a bit more flexible and ##**IIf**## can for example return a reference or even return a function call (but not a sub call).
Deletions:
**Note:** If the condition evaluation can be done at compile time (if the comparison expression is a constant), the usage rules are a bit more flexible and ##**IIf**## can for example return a reference or even return a function call.


Revision [26613]

Edited on 2023-06-30 00:59:39 by fxm [completed description]
Additions:
##**IIf**## returns a different numeric or string or UDT value (not a reference) depending of the result of a conditional expression evaluated at run-time.
When ##**IIf**## treats expressions of mixed numeric types (conditional expression evaluated at run-time):

**Note:** If the condition evaluation can be done at compile time (if the comparison expression is a constant), the usage rules are a bit more flexible and ##**IIf**## can for example return a reference or even return a function call.
Deletions:
##**IIf**## returns a different numeric or string or UDT value (not a reference) depending of the result of a conditional expression evaluated at run-time (evaluation at compile-time only if the comparison expression is a constant).
When IIf treats expressions of mixed numeric types (conditional expression evaluated at run-time):


Revision [26034]

Edited on 2022-06-05 02:06:21 by fxm [added the case of compile-time evaluation]
Additions:
##**IIf**## returns a different numeric or string or UDT value (not a reference) depending of the result of a conditional expression evaluated at run-time (evaluation at compile-time only if the comparison expression is a constant).
Its typical use is in the middle of an expression; it avoids splitting it to put a conditional in the middle.
Deletions:
##**IIf**## returns a different numeric or string or UDT value (not a reference) depending of the result of a conditional expression evaluated at run-time. Its typical use is in the middle of an expression; it avoids splitting it to put a conditional in the middle.


Revision [22582]

Edited on 2019-02-26 08:59:41 by fxm [Suppressed reference to fbc version 0.90]
Deletions:

**Warning:** The ability to accept mixed numeric types, strings and UDTs is only supported from the fbc version 0.90.


Revision [22073]

Edited on 2018-01-11 16:59:36 by JeffMarshall [Add return value section]
Additions:
{{fbdoc item="ret"}}
if ##//condition//## is non-zero, ##//expr_if_true//##, otherwise ##//expr_if_false//##


Revision [21894]

Edited on 2017-09-09 09:27:41 by fxm [Suppressed specific behavior description when condition is resolved at compile-time]
Additions:
##**IIf**## returns a different numeric or string or UDT value (not a reference) depending of the result of a conditional expression evaluated at run-time. Its typical use is in the middle of an expression; it avoids splitting it to put a conditional in the middle.
When IIf treats expressions of mixed numeric types (conditional expression evaluated at run-time):
- if at least one expression is of floating-point type, the result type is the floating-point type (the bigger in case of two floating-point types),
- if the two expressions are of integer types, the result type is the bigger type of both (see [[ProPgDataConversion|Coercion and Conversion]] for the precise ranking of integer types).
Deletions:
##**IIf**## returns a different numeric or string or UDT value (not a reference) depending of the result of a conditional expression. Its typical use is in the middle of an expression; it avoids splitting it to put a conditional in the middle.
In the particular case where the condition is resolved at compile-time, ##**IIf**## returns the original expression itself that satisfies the ##//condition//## (otherwise, it only returns an evaluation of the expression at run-time).
When IIf treats expressions of mixed numeric types:
- if the ##//condition//## is resolved at compile-time:
- the result type is that of the expression satisfying the ##//condition//##,
- if the ##//condition//## can only be solved at run-time:
- if at least one expression is of floating-point type, the result type is the floating-point type (the bigger in case of two floating-point types),
- if the two expressions are of integer types, the result type is the bigger type of both (see [[ProPgDataConversion|Coercion and Conversion]] for the precise ranking of integer types).


Revision [21893]

Edited on 2017-09-09 01:10:15 by fxm [Precised what IIF exactly returns]
Additions:
##**IIf**## returns a different numeric or string or UDT value (not a reference) depending of the result of a conditional expression. Its typical use is in the middle of an expression; it avoids splitting it to put a conditional in the middle.
In the particular case where the condition is resolved at compile-time, ##**IIf**## returns the original expression itself that satisfies the ##//condition//## (otherwise, it only returns an evaluation of the expression at run-time).
Deletions:
##**IIf**## returns a different numeric or string or UDT value depending of the result of a conditional expression. Its typical use is in the middle of an expression; it avoids splitting it to put a conditional in the middle.


Revision [21890]

Edited on 2017-09-05 07:37:16 by fxm [Added the Boolean as expression type]
Additions:
- a numeric value, which can be an integer, floating point number or a pointer, including Boolean,
Deletions:
- a numeric value, which can be an integer, floating point number or a pointer,


Revision [21823]

Edited on 2017-08-17 04:04:35 by fxm [Added the rules for the result type in case of expressions of mixed numeric types]
Additions:
When IIf treats expressions of mixed numeric types:
- if the ##//condition//## is resolved at compile-time:
- the result type is that of the expression satisfying the ##//condition//##,
- if the ##//condition//## can only be solved at run-time:
- if at least one expression is of floating-point type, the result type is the floating-point type (the bigger in case of two floating-point types),
- if the two expressions are of integer types, the result type is the bigger type of both (see [[ProPgDataConversion|Coercion and Conversion]] for the precise ranking of integer types).


Revision [20941]

Edited on 2016-03-13 03:00:47 by fxm [Formatting]
Additions:



Revision [20264]

Edited on 2016-02-10 16:01:11 by DkLwikki [Update link format]
Additions:
- Not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__Iif""**##.
- ##[[KeyPgIfthen|If...Then]]##
Deletions:
- Not available in the //[[CompilerOptlang -lang qb]]// dialect unless referenced with the alias ##**""__Iif""**##.
- ##[[KeyPgIfthen If...Then]]##


Revision [16931]

Edited on 2013-08-31 19:09:02 by CountingPine [May as well abandon the reference to 0.25]
Additions:
**Warning:** The ability to accept mixed numeric types, strings and UDTs is only supported from the fbc version 0.90.
Deletions:
**Warning:** The capacity to accept different numeric types to be mixed, strings and UDTs is only supported from the fbc version 0.25 (version in preview for the version 0.90).


Revision [16929]

Edited on 2013-08-31 14:44:53 by FxMwikki [the fbc version 0.25 is in preview for the version 0.90]
Additions:
**Warning:** The capacity to accept different numeric types to be mixed, strings and UDTs is only supported from the fbc version 0.25 (version in preview for the version 0.90).
Deletions:
**Warning:** The capacity to accept different numeric types to be mixed, strings and UDTs is only supported from the fbc version 0.25.


Revision [16568]

Edited on 2013-02-01 15:08:04 by FxMwikki [IIF now accepts different numeric types to be mixed, strings and UDTs]
Additions:
u2 = Iif(0 , u10, u20)
Deletions:
u2 = Iif(0 ,u10, u20)


Revision [16567]

Edited on 2013-02-01 15:05:58 by FxMwikki [IIF now accepts different numeric types to be mixed, strings and UDTs]
Additions:
{{fbdoc item="filename" value="examples/manual/control/iif4.bas"}}%%(freebasic)
Type UDT1
Dim As Integer I1
End Type
Type UDT2 Extends UDT1
Dim As Integer I2
End Type
Dim As UDT1 u1, u10 = (1)
Dim As UDT2 u2, u20 = (2, 3)
u1 = Iif(0, u10, u20)
Print u1.I1
u1 = Iif(1, u10, u20)
Print u1.I1
u2 = Iif(0 ,u10, u20)
Print u2.I1; u2.I2
'u2 = Iif(1, u10, u20) ''Invalid assignment/conversion


Revision [16566]

Edited on 2013-02-01 09:08:29 by FxMwikki [IIF now accepts different numeric types to be mixed, strings and UDTs]
Additions:
It must return:
- a numeric value, which can be an integer, floating point number or a pointer,
- or a string value,
- or an UDT value.
It must be same type as ##//expr_if_true//## (either numeric, either string or UDT).
##**IIf**## returns a different numeric or string or UDT value depending of the result of a conditional expression. Its typical use is in the middle of an expression; it avoids splitting it to put a conditional in the middle.
**Warning:** The capacity to accept different numeric types to be mixed, strings and UDTs is only supported from the fbc version 0.25.
%%is equivalent to:
{{fbdoc item="filename" value="examples/manual/control/iif3.bas"}}%%(freebasic)
Dim As Integer I
I = -10
Print I, iif(I>0, "positive", iif(I=0, "null", "negative"))
I = 0
Print I, iif(I>0, "positive", iif(I=0, "null", "negative"))
I = 10
Print I, iif(I>0, "positive", iif(I=0, "null", "negative"))
Sleep
Deletions:
It must return a numeric value, which can be an integer, floating point number or a pointer.
It must be the same type of number as ##//expr_if_true//##.
##**IIf**## returns a different numeric value depending of the result of a conditional expression. Its typical use is in the middle of an expression; it avoids splitting it to put a conditional in the middle.
is equivalent to:


Revision [14356]

Edited on 2009-08-29 21:54:29 by CountingPine [Remove CamelCase links in "New to FreeBASIC"]
Additions:
- New to ""FreeBASIC""
Deletions:
- New to FreeBASIC


Revision [13136]

The oldest known version of this page was created on 2008-04-24 15:42:32 by JeffMarshall [Remove CamelCase links in "New to FreeBASIC"]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode