Hello Steve,
Yes, you can do this with use of MapInfo/MapBasic's string functions
such as Left$(), Right$(), Mid$(), InStr() and Len().
Right$() allows you to extract a number of characters from the left of a
string. For instance, to query all the records in a table where the
street name ends in " ave", you could use the following:
select * from MyTable where right$(StreetName, 4) = " ave" into
TO_UPDATE
The "4" means take four characters. Replace "MyTable" with your street
table and "StreetName" with the field containing the street names. The
space before "ave" is to ensure we don't pick up other records which
just happen to have that ending. e.g. "Rue de Gustave".
Left$() does the same but for the left part of strings. Mid$(Str, Pos,
Len) is little more complicated as it picks out "Len" characters from a
starting point, "Pos". InStr() allows you to find the starting place for
a string within a string. This is useful to then use with Mid$().
Finally Len() gives you the total length of a string.
The power really comes from "nesting" one function within another. It's
sometime quit amazing what you can do in a simple statement and not need
a special MapBasic program written for the job. Some expressions look
complicated but they can be understood (and constructed) by starting
from the inside and working out.
So, going back to your requirements, we could find all the avenues by
the query above, then update it to remove the last four characters by:
update TO_UPDATE set StreetName = left$(StreetName, len(StreetName)-4)
Here, we know that all records in our table "TO_UPDATE" end in " ave"
(case not sensitive). So, to take off the ending, we use the length of
the StreetName string, take away 4, and then take the length-4
characters from the StreetName. The update is effectively remove the
endings. There is nearly always more that one way to perform the same
action - just use the string functions as you feel comfortable. Left$()
and Right$() come quite easily, Mid$() and InStr() are just a little
more complicated/
You can type in SQL statements directly into the MapBasic window
(Option>Show MapBasic Window), or use "Table>SQL Select.." and
"Table>Update Column". Although it's a step towards MapBasic
programming, you can do some very clever things with the string
functions presented above. Hope that's useful.
Regards,
Warren Vick
Europa Technologies Ltd, U.K.
http://www.europa-tech.com
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Morrier,
> Steve
> Sent: 23 August 2001 14:28
> To: MapInfo-L
> Subject: MI-L Text Deletion
>
>
> This message is in MIME format. Since your mail reader does
> not understand
> this format, some or all of this message may not be legible.
>
>
> Hi all,
>
> Is it possible to select just a few characters in a column
> and automatically
> delete those characters, leaving just the text you want? For
> example I have
> a huge street file where under street name I have things such
> as first ave,
> main st, etc... I select all streets with "ave" in them, now I want to
> delete the "ave" and leave behind the "first". Is it possible
> to do this
> without deleting everything? Or is this something to be done in Excel?
> Thanks.
>
> Steve
>
>
>
>
> ______________________________________________________________
> _________
> List hosting provided by Directions Magazine | www.directionsmag.com |
> To unsubscribe, send e-mail to [EMAIL PROTECTED] and
> put "unsubscribe MapInfo-L" in the message body.
>
_______________________________________________________________________
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, send e-mail to [EMAIL PROTECTED] and
put "unsubscribe MapInfo-L" in the message body.