I have a problem I really can't seem to get my head around, MapInfo crashes when I try to run and if statement.
I have pretty much exactly the same code in another sub to check for other things and that works perfectly fine. It crashes on the zlRow = TableInfo("zerolengths",TAB_INFO_NROWS), I've tried this with zlRow = TableInfo(0,TAB_INFO_NROWS) as there will only be one TAB file open when this rool is running. I just don't know why it works for other subs and queries but not this!!
Sub LenSub
nMID = FrontWindow()
nLayers = MapperInfo(nMID, MAPPER_INFO_LAYERS)
sLayer = LayerInfo(nMID, nLayers, LAYER_INFO_NAME)
Dim sDir as String
sDir = PathToDirectory$(TableInfo(sLayer,TAB_INFO_TABFILE))
'###Check for blanks
Dim sLen as string
Dialog
Title "Length"
Control statictext
Title "Enter length field"
Control edittext
Value sLen
into sLen
Control OKButton
Control CancelButton
if commandinfo (CMD_INFO_DLG_OK) then
Else
End Program
End if
Run Command "select * from " & sLayer & " where " & sLen & " < 1 into zerolengths"
Dim zlRow as smallint
zlRow = TableInfo("zerolengths",TAB_INFO_NROWS)
if zlRow > 0 then
Export Multipolylines Into sDir & "zerolengths.csv" Type "CSV"
Delimiter ","
Titles
Dialog
Title "Zero lengths"
Control statictext
Title "Sections with zero lengths exported into zerolengths.csv"
Control OKButton
Else
End If
End Sub
Thanks, Alan