1

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

2 Answers 2

1

It seems it is actually crashing on this line

Export Multipolylines Into sDir & "zerolengths.csv" Type "CSV

Does the table Multipolylines exist elsewhere in your code? Did you mean to export the zerolengths table you created instead?

1
  • Yup thanks, still very new to this so I need to be more careful with my pasting!
    – Alan Carr
    Apr 25, 2013 at 16:06
0

First, try to generate your analysis with mainfo and save your espacework like (.Wor) (if you have to open a table and apply an SQL query, Do it manually). then open this file with mapBASIC. Compile it and correct the errors; Add these in the begin of your code to commands:

Declare Sub Main
Sub Main

=============

Add at the end:

 end Sub/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.