User Tools

Site Tools


k10:k10.2:k10.2.2:start

10.2.2 Two-sided selection IFF

Syntax for 2nd variant of the two-sided, alternative selection:

Value = IIf ( Test AS Boolean , TrueExpression , FalseExpression ) 
Value = If ( Test AS Boolean , TrueExpression , FalseExpression ) 

The test expression is evaluated and returns TrueExpression if the expression is TRUE or FalseExpression if the expression is FALSE.

10.2.2.2.1 Example 1

iNumber = 7 
LabelIIF.Text = IIF((iNumber MOD 2) = 0, "N is an even number", "N is an odd number.") 

The text “N is an odd number” is set as label text for iNumber = 7.

10.2.2.2.2 Example 2

In the second example 2 panels are used alternatively in a project to display the graphs of the program' GnuPlot'. First the current (display) panel is determined and then the labeling of the toggle buttons - depending on the current panel - is set:

Public Sub togWhich_Click() 
  $hCurrentPanel = IIF($hCurrentPanel = panPanel1, panPanel2, panPanel1) 
  togWhich.Text = IIF($hCurrentPanel = panPanel1, ("Use lower Panel"), ("Use upper Panel"))
  Print #$hGnuplot, Subst$("set terminal x11 window \"&1\"", Hex$($hPanel.Handle)) 
End ' togWhich_Click() 

Hints:

  • You can also formulate the alternative control structure IFF(selector, A1, A2) as a control structure with IF..THEN..ELSE..ENDIF at any time.
  • The parentheses around the strings “Use lower panel” and “Use upper panel” can be omitted if you have not planned a translation of the program into another language.

Download

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.
k10/k10.2/k10.2.2/start.txt · Last modified: by 127.0.0.1