Hello I am just getting started with MapBasic and I have run in to some trouble trying to count the items in a custom type i have tried accomplishing this by running a loop until an error occur. Problem is that the error trapping does not seem to happen i just keep getting a dialog with an out of range error message what am I missing here? My code is as follows:
Type KeyValuePair
Pos As Integer
Key As Integer
StringVal As String
End Type
Type PopupMenu_Items
ControlId As Integer
Values() As KeyValuePair
End Type
Sub CountPopupMenu_Items (countResult As Integer, arrayToCount() As PopupMenu_Items)
Dim i As Integer
Dim controlId As Integer
i = 1
Do While i = i
controlId = arrayToCount(i).ControlId
OnError Goto endOfArray
i = i + 1
Loop
last_exit:
exit sub
endOfArray:
countResult = i - 1
resume last_exit
End Sub