MapInfo Pro

 View Only
  • 1.  MapBasic - batch abbreviating of road names

    Posted 20 days ago

    Can MapBasic (for MapInfo 23.2) do batch abbreviating of road names, please?

    By this I mean in three tables I have (Pipes, Pits and Prop), there is in each a road name field called "St_Name", and the road names are in full, eg. Main Street, Jones Road, Smith Crescent (and so on).

    What I'm looking for is something like the 'Search and Replace' tool 'on steroids', ie. it is able to change 'Road' to 'Rd', 'Street' to 'St', 'Crescent' to 'Cr' (and so on for other road types) without affecting the 'Main', 'Jones', 'Smith', etc.
    Ideally, it can do all 3 tables at once to speed things up (but will be happy doing one table at a time if need be).
    There are a couple of caveats for this, in that a small proportion of the features in these tables have a blank entry in the "St_Name" field, or otherwise something like "Lot B"; so such a MapBasic app needs to be able to work around this. Most features will have road names such as above.

    With the help of ChatGPT earlier today on my work PC (which is where it will be used) I was able to create an app in MapBasic that compiled OK, but still came up with an error when running in MapInfo.

    Thanks, John



    ------------------------------
    John Cleverdon
    Director
    John Cleverdon
    DROMANA VIC
    ------------------------------


  • 2.  RE: MapBasic - batch abbreviating of road names
    Best Answer

    Posted 19 days ago
    Edited by Peter Møller 10 days ago

    I would most likely export the tables to MIF/MID and then use something like notepad++ to search and replace, before importing again.

    If you want to do it with mapbasic, you can look at mblibrary, which has this function in module stringlib.mb:

    Function STRINGReplace(ByVal sToBeSearched As String, ByVal sSearchFor As String, ByVal sReplaceWith As String) As String

    Find it here: https://github.com/PeterHorsbollMoller/mbLibrary

    Finally there is also a "Search and replace" tool in the list of default tools.



    ------------------------------
    Uffe Kousgaard
    CEO
    Routeware v/Uffe Kousgaard
    Roskilde
    ------------------------------



  • 3.  RE: MapBasic - batch abbreviating of road names

    Posted 17 days ago

    Thank you for the feedback, Uffe. I'll try out the MB app in the coming week or as time permits.
    The comment about MIF/MID files is interesting because the asset management data in the tables mentioned is imported into MapInfo from MIF/MID files.

    Regards, John



    ------------------------------
    John Cleverdon
    Director
    John Cleverdon
    DROMANA VIC
    ------------------------------



  • 4.  RE: MapBasic - batch abbreviating of road names

    Posted 10 days ago

    A follow-up,  I tried editing the mid files in Notepad++ and found that it could edit multiple files simultaneously (eg. Road to Rd), so will use that for the time being.

    Regards,  John 



    ------------------------------
    John Cleverdon
    John Cleverdon
    ------------------------------