Is it possible to use code to convert a integer (0 or 1) to it’s corresponding boolean value?
EDIT: The code:
[code]Dim s1 As Shell
s1 = New Shell
#If TargetMacOS Or TargetLinux Then
s1.Execute(“defaults read com.company.app whatevervalue”)
#Endif
If s1.Result = “1” then
me.InitialValue=“Mode 1”
me.AddRow(“Mode 2”)
else
me.InitialValue=“Mode 2”
me.AddRow(“Mode 1”)
end if[/code]
EDIT 2:
The value returned from my shell command will be 0 or 1, so I just wanna convert that to Boolean for use in If Then statement.
myBool = if(myInt = 1, true, false)
This code:
[code]Dim s1 As Shell
s1 = New Shell
#If TargetMacOS Or TargetLinux Then
s1.Execute(“defaults read com.company.app whatevervalue”)
#Endif
Dim booly as Boolean
booly = if(s1.Result = 1, true, false)
If booly = true then
me.InitialValue=“Mode 1”
me.AddRow(“Mode 2”)
else
me.InitialValue=“Mode 2”
me.AddRow(“Mode 1”)
end if[/code]
Gives me the error
[quote]Type Mismatch Error. Expected String, but got Int32
booly = if(s1.Result = 1, true, false)[/quote]
Whatever. I resolved it and just used a button and called it toggle modes instead of using a popup menu.
[quote=234337:@Eric Williams]Even easier:
myBool = myInt = 1
Thanks for replying, but as I said, I’ve resolved it.
Cheers,
Julian
That’s because the return value from Shell is a string and not an Integer. The code I had provided was set up for an Integer.
[quote=234337:@Eric Williams]Even easier:
myBool = myInt = 1
Orly? I’ll have to try that sometime.