11

Also if you are looking for a way to learn MapBasic more than a way to learn programming, there is a huge help in MapInfo Pro thru the MapBasic window. Open the MapBasic window (Options > Show MapBasic Window) and do the task you want to code in MapBasic in MapInfo Pro. MapInfo Pro will now write the MapBasic statements required. You can now copy these into ...


7

MapInfo Pro does not support the Distinct keywork, unfortunately. However you can get to the same result just be grouping your result by the column Select some_column from table_name into temp_table Group By some_column


7

I'm going to attempt to answer this in more general way as I believe it's more useful long term to have a bit of a tutorial rather than a straight code dump (also I tend to think you should be paying someone for a straight up code translation, even if it is only a couple of hundred lines of code). If you don't understand Python I'd strongly recommend reading ...


7

The last few versions of MapInfo Professional can read KML files directly thru File > Open Universal Data.


7

A Function always returns a value where as a Sub does not. All methods in MAPBASIC can have side effects in the true term because it's not a functional language. If you are expecting a return value you should use a Function that is what they are there for. Can you modify the value of myParameter inside a Sub and then just use it after. Yes. But this ...


6

I was lucky enough to learn MapBasic from some other colleagues. I have not found many resources for MapBasic other than what Pitney Bowes offers on the site. I spotted this tutorial that looks fairly good for new starters. Online Forum Knowledge Base MapBasic Product Documentation v9 link. There is currently only a handful of MapBasic questions on this ...


6

Query For Selecting row(s) without object : Select * from 'MYTABLE' where not obj into MYTABLE_NO_MAP_OBJECT Browse * From MYTABLE_NO_MAP_OBJECT Query For Selecting row(s) with object : Select * from MYTABLE where obj into MYTABLE_MAP_OBJECT Browse * From MYTABLE_MAP_OBJECT


6

Just sue the CreateCircle method in the MapBasic window, or just put it behind a quick and dirty dialogue with all the maths worked out behind the scene Create circle in MapBasic CreateCircle( x, y, radius ) x is a float value of the circle's center. y is a float value of the circle's center. radius is a float value, indicating the circle radius. As ...


5

This will close all layers except one using a layer name to check what to keep open: Dim i as Integer Dim tables as Integer Dim tableName as String tables = NumTables() For i = 0 To tables tableName = TableInfo(i,TAB_INFO_NAME) '' Check to see if the table is anything but the one we are looking for. If Not tableName = "{Your table name to ...


5

You can add NOSELECT to the end of the query. Example from the user guide: Select * From World Into EarthQuery NoSelect


5

Well that wasn't so hard. Declare Sub Main Declare Function RemoveSpecialChars(byval str as string) as String Sub Main Dim t as string t = "this is a string with spaces and ' ! * & ^ % $ £ punctuation" Print Chr$(12) + "Original String: " + t Print "Tidy string: " + RemoveSpecialChars(t) End Program End Sub Function ...


5

You can use the Mapping Wizard Tool to load in your text file of latitude and longitude coordinates. Just set the correct datum (usually World WGS84) to overlay them correctly. Guide to using the Mapping Wizard Tool: http://www.oocities.org/mapinfotutorial/wizard.html


5

Let's say we have two tables: Tab1 with field Field1, Tab2 with field Field2. We want to select records from Tab1 which Field1 values is not present in Field2 of Tab2. In MapInfo: menu Query->SQL Select... Columns: * from Tables: Tab1 where Condition: not Field1 in (select Field2 from Tab2) In MapBasic window it will be: Select * from Tab1 where not ...


5

MapBasic, the scripting language of MapInfo Pro, has a number of functions/statements that can be helpful for you: TableInfo(): can be used to get basic information about an open table PathToTableName$(): can extract the table name, as MapInfo Pro sees it, from a file path PathToFileName$(): can extract a filename with extension from a file path Update: can ...


5

I searched for "mapbasic regex" and found what looks to be what you may need posted in the nyalldawson.net blog: If you’re not familiar with regular expressions, they’re an extremely powerful tool for string manipulation. They can be somewhat daunting at first, but with a bit of practice they’ll open up all kinds of string processing which would ...


4

How about running an SQL join: select tab1.attr1, tab1.attr2 from tab2, tab1 where Tab1.Site_ref = Tab2.Site_ref into q_ToSave commit table q_ToSave as "C:\NewTable.tab" This works. If Tab1 doesn't have objects in it then the order of the tables in the from clause is not important, but if there are objects in tab1 to be replaced, then specifying tab2 ...


4

If you only have to do it once and there is only two points I would just do it by hand, else you can use a tool called ConnectTheDots.MBX which can be found here: http://www.mapinfotools.com/index.php?option=com_sobi2&sobi2Task=sobi2Details&catid=10&sobi2Id=35&Itemid=53


4

Not a tutorial but something I found very useful is this site: http://www.twiav.nl/php/mapbasic.php I would highly recommend setting up Notepad++ (or something similar). Syntax highlighting, bulk indenting and bulk commenting can speed things up massively.


4

Select * from 'table' Where RowID = n If you want it into a selection table of your choice, put the selection into somename, then browse * from somename If not, just Browse from selection edit This is all from memory, so please play about and also read the online reference manual: MapBasic Ref MapInfo -L


4

Try this in stead: Dim count As Integer Select count(*) "mycount" from some_table into temp_table Fetch First From temp_table count = temp_table.mycount


4

Shouldn't be that hard to write your own procedure for doing that: Sub ARRAddItem(arrValues() As String, ByVal sNewValue As String) Dim nItem As Integer nItem = Ubound(arrValues) + 1 Redim arrValues(nItem) arrValues(nItem) = sNewValue End Sub Note that it will resize the array with one and insert the value at this index


4

You can just run the SQL command right in the MapBasic code: Select * from some_table into mySelection If you do need to store the SQL query in a string (dynmic SQL string etc) you can execute it using RunCommand Dim query As String query = "Select * from some_table into mySelection" Run Command query In order to get the values from the table you need ...


4

I wonder if it's because the output.shp hasn't been constructed properly? Check to see that the output is formatted fully - ie; ends in output.shp Try changing: OGR2OGR -f "ESRI Shapefile" "S:\000 GIS Files\TEST WORKSPACE 2\convert test\Converted\SHP\" "S:\000 GIS Files\TEST WORKSPACE\SiteForm.TAB" -overwrite -skiperrors to... OGR2OGR -f "ESRI Shapefile"...


4

You have to use Mapinfo.Eval and MapInfo.Do and wrap the other requests. You can't simply call MapBasic functions in Integrated mapping, you need to do them through these two methods, if I remember correctly. So, something like this: If mapinfo.Eval("TableInfo(" & tabName & "," & 5 & ")") = "F" Then MsgBox "Cannot open table!" mapinfo....


4

What you will need to do is write a MapBasic script something like the following. Firstly, query your table. If you have co-ordinates stored as numbers in the table, the query will be something like this: select x_column, y_column from yourTable [where condition] into MyQuery Otherwise you need something like: select CentroidX(obj), CentroidY(obj) from ...


4

Functionally this code does the same thing (in QGIS 2.0): vl = QgsVectorLayer("LineString", "lines", "memory") vl.startEditing() dp = vl.dataProvider() layer = QgsMapLayerRegistry.instance().mapLayersByName("points")[0] dp.addAttributes(layer.pendingFields()) for feature in layer.getFeatures(): x1, y1, x2, y2 = (feature["x1"].toFloat()[0], ...


4

Your dialog has at least three controls: A Edit text control with an ID A Button with the title "Browse" A OKButton with the title "Upload" When you click the Browse button you should call a handler (a sub procedure) where you use the FileOpenDlg() function to ask the user to pick a file of a certain type. Then you should add the selected file name to the ...


4

Let's start by looking at your two statements: This statement will close the MapBasic Window: Close Window WIN_MAPBASIC This statement will end your MapBasic application and unload it from memory: End Program If you want to shot down MapInfo Professional, you should run this statement: End MapInfo Interactive The keyword 'Interactive' makes sure that ...


4

Have a look at these threads: Creating an annulus sector with MapBasic Drawing BTS Sectors in GSM For the looping I expect that you have your data in a table that you can loop over. If so you can use this structure for the looping: Fetch First From PRACH_TABLE Do Until EOT(PRACH_TABLE) '**Do the work here Fetch Next From PRACH_TABLE Loop


4

A few suggestions for doing grid interpolation with MapInfo Pro/MapBasic No add-ons In MapInfo Pro without add-ons gridding is part of the thematics. But you only have a few interpolation methods to pick from, TIN and IDW. To get a look at the MapBasic code, try creating a Gridding Thematic using MapInfo Pro or have a look at the Create Grid statement in ...


Only top voted, non community-wiki answers of a minimum length are eligible