IIF$
<< Click to Display Table of Contents >> Navigation: ThinBASIC Core Language > BuiltIn Functions > String functions > IIF$ |
Description
Return TruePartStringExpression of FalsePartStringExpression depending on Num_Expression avaluates to True or False.
Syntax
s = IIF$(Num_Expression, TruePartStringExpression, FalseStringExpression)
Returns
String
Parameters
Name |
Type |
Optional |
Meaning |
Num_Expression |
Numeric |
No |
Numeric expression to valuate. It will be checked if %FALSE or %TRUE. |
TruePartStringExpression |
Numeric |
No |
If Num_Expression will valuated to %TRUE, this sting expression will be returned. |
FalseStringExpression |
Numeric |
No |
If Num_Expression will valuated to %FALSE, this sting expression will be returned. |
Remarks
Restrictions
See also
Examples
Thanks to Abraxas for the following script example
' Usage of the IIF$ Keyword example
' Changes the button text depending on which one is clicked
USES "UI"
Dim hDlg As DWORD
Dim Msg, wparam,lparam As DWORD
Dim buttext As String VALUE "Red Pill"
DIALOG New 0, "IIF$ Example", -1, -1, 300, 100, _
%WS_POPUP Or _
%WS_VISIBLE Or _
%WS_CLIPCHILDREN Or _
%WS_CAPTION Or _
%WS_SYSMENU Or _
%WS_MINIMIZEBOX , _
0 To hDlg
CONTROL ADD BUTTON, hDlg, 1001, Buttext, 50, 50, 90, 20
CONTROL ADD BUTTON, hDlg, 1002,"Blue Pill", 150, 50, 90, 20
DIALOG SHOW MODELESS hDlg
While ISWINDOW(hDlg)
Msg = GETMESSAGE(hDlg, wParam, lParam)
Select Case Msg
Case %WM_Command
' IIF$ checks which buttons clicked and changes the text of a button
buttext = IIF$ (wParam = 1001, "Try the blue pill", "Red Pill")
CONTROL Set Text hDlg, 1001, buttext
If (wParam = 1002) Then Exit While
Case %WM_SYSCOMMAND
If wParam = %SC_Close Then Exit While
End Select
Wend
DIALOG End hDlg