Navigation:  thinBasic Modules > Core > String handling >

IIF$

Previous pageReturn to chapter overviewNext page

 

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

 

String Handling, IIF,

 

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   ,  _

                                     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

 

 

 

 

© 2004-2008 thinBasic. All rights reserved. Version 1.7.0.0 Web Site: http://www.thinbasic.com