Dear All,

Searching through the archives for some assistance with text-manipulation,
I came across a message with an explanation of how to remove a bracketed
section from a variable.

The example was removing the "3557004" from " Hilton (3557004) TP 00000 "

The quoted mapbasic code didn't work, so after finding the Mapbasic manual,
I managed to work out that

mid$(var, instr(1,var,"(")+1, instr(1,var,")")- instr(1,var,"(")-1)

is the correct code.

To explain,
Mid$ = returns a string from the middle of another string,
var = variable_name
instr = position within string
so:

We need to work out how to get to     mid$(var,9,7) = 3557004  <7 chars.
from 9th char>)

with    instr(1,var,"("        = 8    < 8 characters being "Hilton (">
and    instr(1,var,")"      = 16   < Hilton (3557004)>

mid$(var,(8+1),((16-8)-1))  <note - this doesn't come out as 16-(8-1) = 9>
mid$(var,9,(8-1))
mid$(var,9,7) = 3557004

With apologies to Jaques Paris.

Regards,

Brian Forrester
Wood Mackenzie
Edinburgh
[EMAIL PROTECTED]
www.woodmac.com




----------------------------------------------------------------------
To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put
"unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]

Reply via email to