DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Using boolean variable with Select Case

Solved!
Go to solution

I have setup a dialogue box with two radio buttons and allocated B1 as a variable for it, having a value of either 0 or 1 depending on the choice of radio button.

I then use Select Case to examine the value of B1 and find that Case 0 and Case 1 doesn't work, but Case False and Case True does. My code is:

B1=1
Call SUDDefLoad(AutoDrvUser&"Actions.sud")
Call SUDDlgShow("Analysis")

if DlgState = "IDOk" then Select Case B1 Case False Call ScriptStart("GetData") Case True Call ScriptStart("GetContData") End Select else Flag = 0 Call Err.Raise (-1) 'Autoquit end if

A similar dialogue box written by a colleague uses the same concept for the radio buttons and variable, but his code works because he uses an If statement to determine the value of B1. His code is:

B1=0
Call SUDDlgShow("Decimate")

if DlgState <> "IDOk" then
  Call Err.Raise (-1) 'Autoquit
end if

If B1=0 Then
  NoPts = Val(T1) 
Else 
  NoPts = L2/Val(T1)
End If

Why the difference in behaviour with the use of B1?

Thanks,

Simon.

 

0 Kudos
Message 1 of 4
(254 Views)
Solution
Accepted by topic author Simon_Aldworth
01-17-2019 01:04 AM

would it ever be true?

Capture.JPG

0 Kudos
Message 2 of 4
(237 Views)

The confusion deepens. You seem to have proved that B1 cannot use 0 or 1, and must use True or False instead. 

 

I tested my colleague's code and it seems you are correct. His code only worked because he used "If B1=0" and "Else", which is the only case that turns out true in your experiment!! I have changed his code to use True and False.

 

However, the DIAdem help files state that a Boolean variable type can take the values TRUEFALSE or "YES", "NO" or 10. See here for example in 2018 online help. Not at all helpful!!

 

Regards,

 

Simon.

0 Kudos
Message 3 of 4
(224 Views)

The docs are fooling us... the only "truthy" value i found was -1

0 Kudos
Message 4 of 4
(221 Views)