Hi
I'm writing my first MapBasic script and I cannot make it work. Maybe someone can give me some advice? My aim is to modify this SQL
-----
Select Polygon_to_update.ID,Polygon_to_update_from.obj "NewObj",Polygon_to_update.obj
from Polygon_to_update,Polygon_to_update_from
where Polygon_to_update.ID=Polygon_to_update_from.ID
into TableX NoSelect
Update TableX Set OBJ=NewObj
-----
so that it utilizes user defined table names. This SQL (originated from
https://groups.google.com/forum/m/#!topic/mapinfo-l/bhnSNBad1xU) works fine. Basically, with this SQL I can substitute geometry from table "Polygon_to_update" with the geometry in table "Polygon to update from" and retain original tabular data in table "Polygon_to_update".
In MapBasic (Version 17.0; 64-bit; Release Build 73) I have this:
-------
Include "mapbasic.def"Include "mapbasic.def"
Dim table_to_update As String
Dim table_to_read_from As String
Dim query As String
Dialog
Title "Enter table name 1"
Control StaticText
Title "Enter table name to be updated"
Control EditText
Into table_to_update
Control OKButton
Control CancelButton
If CommandInfo(CMD_INFO_DLG_OK) Then
End If
Dialog
Title "Enter table name 2"
Control StaticText
Title "Enter table name to read from"
Control EditText
Into table_to_read_from
Control OKButton
Control CancelButton
If CommandInfo(CMD_INFO_DLG_OK) Then
End If
query="Select "+table_to_update+".ID"+","+table_to_read_from+".obj"+" "+"""NewObj"""+","+table_to_update+".obj"+" from"+table_to_update+","+table_to_read_from+" Where "+table_to_update+".ID"+"="+table_to_read_from+".ID"+
+" into TO_BE_UPDATED NoSelect Update TO_BE_UPDATED Set OBJ=NewObj"
Run Command query
------
In MapBasic it compiles with no errors. When I run this .mbx in MapInfo Pro (Version 17.0.4; 64-bit; release buld 3) I can type table names in dialog boxes but after that I get error (attachment "Error_message"). How to correct this error?
Thank you
Asko Põder
Estonian Agricultural Board
Senior Specialist
------------------------------
Asko Põder
Knowledge Community Shared Account
------------------------------