ICase Function | |
Evaluates the results from a list of conditions (upto 100 pairs are supported).
Namespace:
XSharp.VFP
Assembly:
XSharp.VFP (in XSharp.VFP.dll) Version: 2.21
Syntax FUNCTION ICase(
lCondition,
eResult,
lCondition2,
eResult2,
eOtherwiseResult
) AS USUAL CLIPPER
[ClipperCallingConventionAttribute(new string[] { ... })]
public static Usual ICase(
Usual lCondition = default,
Usual eResult = default,
Usual lCondition2 = default,
Usual eResult2 = default,
Usual eOtherwiseResult = default
)
Request Example
View SourceParameters
- lCondition (Optional)
- Type: Usual
Specifies a condition as a logical expression to evaluate.
If lCondition evaluates to False (.F.), ICase( ) continues to evaluate the next condition and returns the corresponding eResult for that
condition if it evaluates to True (.T.).
If lCondition evaluates to null (.NULL.), X# treats lCondition as if it evaluated to False (.F.).
- eResult (Optional)
- Type: Usual
Specifies a result to return if lCondition evaluates to True (.T.). - lCondition2 (Optional)
- Type: Usual
Specifies a condition as a logical expression to evaluate.
If lCondition2 evaluates to False (.F.), ICase( ) continues to evaluate the next condition and returns the corresponding eResult for that
condition if it evaluates to True (.T.).
If lCondition evaluates to null (.NULL.), X# treats lCondition as if it evaluated to False (.F.).
- eResult2 (Optional)
- Type: Usual
Specifies a result to return if lCondition2 evaluates to True (.T.). - eOtherwiseResult (Optional)
- Type: Usual
Contains the result returned if all conditions evaluate to False (.F.).
Return Value
Type:
UsualICase( ) returns the first eResult as soon as lCondition evaluates to True (.T.).
If all conditions evaluate to False (.F.),
ICase( ) returns eOtherwiseResult.
If eOtherwiseResult is omitted, and all conditions evaluate to False (.F.),
ICase( ) returns null (.NULL.).
Remarks
You must always pass a set of two parameters to ICase( ).
If you pass an odd number of parameters, the last parameter is treated as the return value for eOtherwiseResult.
You can pass up to 100 pairs of parameters for ICase( ).
If you use a long ICase( ) expression in a filter expression, such as in a FOR or WHERE clause,
make sure that Sys(3055) is set to an appropriate complexity level to avoid generating an error.
For more information, see Sys(3055) - FOR and WHERE Clause Complexity.
Examples
The following example demonstrates different scenarios using
ICase( ) to evaluate expressions and returning certain values based on the results of those expressions.
The following line of code displays "First is true" because the first expression evaluates to True (.T.).
1? ICase(1+1=2,"First is true",1+1=3,"Second is false","None are true")
The following line of code displays "Second is true" because the first expression evaluates to False (.F.), but the second expression evaluates to True (.T.).
1? ICase(1+2=2,"First is false",1+2=3,"Second is true","None are true")
The following line of code displays "None are true", which is the last result specified, because the first and second expressions evaluate to False (.F.).
1? ICase(1+2=2,"First is false",1+1=3,"Second is false","None are true")
See Also