Bad IF .. THEN .. ELSE .. ENDIF coding doesn't give an error
issueid=502 21-01-2016 23:02
Member
Number of reported issues by dcromley: 12
Bad IF .. THEN .. ELSE .. ENDIF coding doesn't give an error
Some others may make the same mistakes that I have

Some other languages (VBA, Javascript, PHP) have various IF THEN ELSE syntax.
I have used the wrong syntax before and instead of giving an error, the execution hangs up.
I wonder how hard it would be to check for the following bad syntax?
(Low priority -- I don't mean to be obnoxious)

' for TRUE:
'   line TF1 hangs
'   line TF2 hangs
'   line TF3 OK
' for FALSE:
'   line TF1 hangs
'   line TF2 hangs
'   line TF3 doesn't print "F3"

  Uses "console"

Sub TBMain()
  Sub1(TRUE) ' or false
  PrintL "End"
  WaitKey
End Sub  

Sub Sub1(condition As Boolean)
  If condition Then ' correct syntax
    PrintL "--TRUE--"
  Else
    PrintL "--FALSE--"  
  End If
  
  If condition Then PrintL "T1" Else PrintL "F1" ' line TF1
  
  If condition Then PrintL "T2" ' line TF2
  Else PrintL "F2"
        
  If condition Then: PrintL "T3": Else: PrintL "F3": End If ' line TF3
End Sub
Issue Details
Issue Number 502
Issue Type Task
Project thinBasic
Category Core engine (thinCore.dll)
Status Requested
Priority 10 - Lowest
Target Version 1.9.16.x
Completed Version (none)
Milestone (none)
Votes to perform 0
Votes not to perform 0
Assigned Users (none)
Tags (none)




22-01-2016 12:50
thinBasic author
Thanks for reporting.
I will try to catch all possible cases in future updates.

23-01-2016 11:49
thinBasic author
Some improvements will be present in next release.

+ Reply