Code: Select all
Sub Main()
dim A as single, B as single, error as byte
error = TestFunction(0, A, B)
End Sub
public function TestFunction(byval mode as byte, byref Var1 as single, byref Var2 as single) as byte
debug.print "mode @ start="; mode
if mode = 0 then
debug.print "mode in case 0="; mode
debug.print "Correct Result"
else
'debug.print "modeElse="; mode
end if
debug.print "mode @ end ="; mode
TestFunction= 1
end function
Note that "Correct Result" is not printed out.ZBasic v2.6
mode @ start=0
mode @ end =0
If the debug statement in the "Else" case is uncommented, the result is correct:
This is very unusual, as I don't quite see how the "Else" case influences branching...ZBasic v2.6
mode @ start=0
mode in case 0=0
Correct Result
mode @ end =0
=================================
EDIT: A more simple example is shown below.
If the Else is in the If..Then statement, there is no entrance into any of the If branches, and nothing is printed out between the first and last coded debug statements.
If the Else and associated statements are removed, then "Correct Result" is printed out as it should be.
Code: Select all
Sub Main()
dim var1 as byte = 1
debug.print "var1 @ start="; var1
if var1 = 1 then
debug.print "var1 in case 1"; var1
debug.print "Correct Result"
else
debug.print "var1 in case else="; var1
debug.print "Incorrect Result"
end if
debug.print "mode @ end ="; var1
end sub