IDE bug

SPLatMan

Member
Licensed User
Longtime User
I know it can be devilishly difficult to get a compiler to exactly nail an error. However, this one had me really vexed. The compiler reports "Missing End Sub" on the last but one line of this sub:
B4X:
Sub doHMIOpenFile(BaseName As String, Mode As String) 'Create or switch to a different logging file. BaseName may include an extension
   Dim S As String
   Dim N, M, K As Int

   If IsNumber(Mode) Then
      M = Bit.And(Mode, 3)   'AND to protect against silly users
   Else
      M = -1
   End If

   If BaseName <> "" Then      'Caller gave a name
      K = GetFCB(BaseName)   'Find out if it already has an FCB
      If (K = -1) AND (M <> -1 Then)   'No FCB, Mode is specified ... create FCB
         N = CreateFCB(BaseName, M)   'CreateFCB takes care of errors and messages
         If N >= 0 Then
            CurrentFCB = N
         End If
      Else
         CurrentFCB = K
      End If
   Else
   
   
   End If
End Sub
I finally nailed it by block commenting lumps of code and narrowed down the error, which is pretty hard to spot - a Then that had snuck inside a closing paren.

David Stonier-Gibson
Samsung Galaxy ACE, 2.3.4
SPLat Controls - OEM Embedded Machine Controllers
 
Top