I'm writing a mapbasic create point statement and getting an argument out of range error when running the code. I've been though it a hundred times and can't figure out where my mistake is. I'm hoping some other eyes on the code might spot something that I'm missing. Basically the code assigns a create point function to a button on a toolbar; when the user clicks the button the cursor changes to crosshairs and when they click a point is created and a dialog opens where variables can be entered.
I'm only including the relevant declarations, etc. The error occurs right after the button on the toolbar is clicked (before the click event/point is created) and the line given on the error message is indicated in the syntax below:
Sub RefineryCreator Dim sFeatureName, sDestTable, sAerialLoc, sSym, sOwnerName, sSource, sSourceDate as String Dim sOwner(), sOwnerID() as String Dim i, iOwner, iOwnerID, iStatus as Integer Dim lAerial as Logical Dim oObj as Object Dim fX, fY, fBCD as Float Dim symOne as Symbol Dim aOwner, aOwnerID as Alias Open Table sAppPath + "data_files\oil_companies.tab" as refinery_owners Select * From refinery_owners Order by Company_Name Into _owners NoSelect ReDim sOwner(TableInfo(_owners, TAB_INFO_NROWS)) aOwner = _owners + ".Company_Name" ReDim sOwnerID(TableInfo(_owners, TAB_INFO_NROWS)) aOwnerID = _owners + ".Company_ID" For i = 1 to TableInfo(_owners, TAB_INFO_NROWS) Fetch Rec i From _owners sOwner(i) = aOwner sOwnerID(i) = aOwnerID If sOwner(i) = sOwnerName Then iOwner = 1 End If Next Close Table refinery_owners symOne = MakeSymbol (34, 7585792, 12) fX = CommandInfo(CMD_INFO_X) fY = CommandInfo(CMD_INFO_Y) oObj = CreatePoint(fX,fY) Alter Object oObj Info OBJ_INFO_SYMBOL, symOne Dialog Title "Create New Refinery" Control StaticText Title "Name:" Position 5,0 Control EditText Position 15,0 Width 100 Value "" Into sFeatureName Control StaticText Position 5,20 Title "Owner:" Control PopupMenu Position 15,20 Title From Variable sOwner Value iOwner Into iOwner Control CheckBox Position 5,40 Title "Aerial Imagery?" Value lAerial Into lAerial Control RadioGroup Position 5,55 Title "Proposed;Idle;Operating;Shutdown" Into iStatus Control StaticText Title "BCD:" Position 5,115 Control EditText Position 15,125 Width 15 Value "" Into fBCD Control StaticText Title "Source:" Position 5,145 Control EditText Position 15,145 Width 100 Value "" Into sSource Control StaticText Position 5,160 Title "Source Date:" Control EditText Position 30,160 Width 75 Value "" Into sSourceDate Control OKButton Control CancelButton If CommandInfo(CMD_INFO_DLG_OK) = FALSE then Exit Sub ElseIf CommandInfo(CMD_INFO_DLG_OK) = TRUE then sOwnerName = sOwner(iOwner) iOwnerID = sOwnerID(iOwner) End if sDestTable = "C:\work\oil_layers\Oil_Refineries_dev.TAB" If lAerial = TRUE and sSource <> "Aerial Imagery" then sAerialLoc = "1" Insert Into sDestTable ( Name, Other_Name, Owner, Owner_ID, Previous_Owner, State, County , Zip_Code, Rank, BCD, Source, Loc_Code, Release_Source, Source_Date , Developer, Status, Notes, Last_Updated, Layer_ID, Rec_ID) Values ( sFeatureName, "", sOwnerName, iOwnerID, "", "", "", "", "" , fBCD, "Aerial Imagery" + sSource, sAerialLoc, "Aerial Imagery" , sSourceDate, sUserName, iStatus, "", CurDate(), "915", "") Else Insert Into sDestTable ( Name, Other_Name, Owner, Owner_ID, Previous_Owner, State, County , Zip_Code, Rank, BCD, Source, Loc_Code, Release_Source, Source_Date , Developer, Status, Notes, Last_Updated, Layer_ID, Rec_ID) Values (sFeatureName, "", sOwnerName, iOwnerID, "", "", "", "", "" , fBCD, sSource, "3", "ABB Research", sSourceDate, sUserName , iStatus, "", CurDate(), "915", "") Commit Table sDestTable End If End Sub
(then a dialog is created where the user can assign variables for insertion into table, followed by the insert statement)