Saturday, 9 November 2019

labeling - Search for string and only display characters before it in Mapinfo label expressions


So I have a property table that has addresses like below.


12 Andrews CL, Pxxx
1/12 Andrews CL, Pxxx
2/31 Macrossan ST, Pxxx
2/7-11 Barrier ST, Pxxx


I need to only show


12
1/12
2/31
2/7-11

Can this be done within the expression builder in Mapinfo 12?


In python it would be something like address[:address.find(' ')]



Answer



Yes, you can do this by using the Left$ and InStr functions as below. Check out the MapBasic Reference Guide (should be available in the Documentation folder of your MapInfo installation) for detailed information about those functions, along with a whole host of others.



Left$(address,InStr(1, address, " ") - 1)

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...