Public Sub Main()
Dim bTest As Boolean
Dim iValue As Integer[] = [1, 2]
If bTest And iValue[2] = 5 Then Print "Hello"
End
"And" query
- cogier
- Site Admin
- Posts: 1125
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
"And" query
If you look at the code below you will see that the IF statement will fail as bTest is False so why do I get an 'Out of bounds' error from the fact that iValue[2] does not exist. I would have expected that iValue would not be checked as the first part failed. Does this happen in other languages?
Re: "And" query
Hi cogier, Gambas is checking your code first and finding an error (that the assignment of the value is illegal or out of bounds). It hasn't got to the stage of evaluating the If expression yet.
- cogier
- Site Admin
- Posts: 1125
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: "And" query
Thanks guys, the 'And If' fixed it.