Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

share|improve this question

1 Answer 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?

share|improve this answer
    
Yup thanks, still very new to this so I need to be more careful with my pasting! –  Alan Carr Apr 25 '13 at 16:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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