This MapBasic sub procedure that I wrote might be helpful


'*************************************************************************
'Removes all occurrences of a (1) given type of character from a given text 
field
'*************************************************************************
sub RemoveChar(byval theTab as string ,byval theField as string,byval theChar 
as string)
Dim uTab,cmdString,tempString,newString,rightString,leftString as string
Dim nRows,j,charPlace,LenTempString as integer
Dim theFieldAl as alias

        set table theTab fastedit on undo off
        
        'Get a unique temporay table name
        uTab = "temp"
        theFieldAl = uTab+"."+theField
        Do
        
                cmdString = "select * from "+theTab+" where 
InStr(1,"+theField+","+dq+theChar+dq+") > 0 into "+uTab
                run command cmdString
        
                for j = 1 to tableinfo(uTab,8)
                        fetch rec j from uTab
                        tempString = theFieldAl
                        charPlace = InStr(1,tempString,theChar)
                        LenTempString = Len(tempString)
                        'if the character is at the end of the string
                        if charPlace = LenTempString then
                                newString = Left$(tempString,LenTempString-1)
                        
                        'if the character is at the start of the string
                        elseif charPlace = 1 then
                                newString = Right$(tempString,LenTempString-1)
                        else
                                'Get the left side of the string
                                leftString =Left$(tempString,charPlace-1)
                        
                                'Get the right side of the string
                                rightString = Right$(tempString,LenTempString - 
charPlace)
                        
                                newString = leftString + rightString
                        end if
        
                        update uTab set theField = newString where rowid = j
                        if j mod 1000 = 0 then
                                commit table theTab
                        end if

                
                next
        
                Commit table theTab
                close table uTab
        
                cmdString = "select * from "+theTab +" where 
InStr(1,"+theField+","+dq+theChar+dq+") > 0 into "+uTab
                run command cmdString
        
                nRows = tableinfo(uTab,8)
        
        Loop While nRows > 0

        if tableopen(uTab) then
                close table uTab
        end if

        set table theTab fastedit off undo on
        
end sub



-----Original Message-----
From: Zhang, Jiye [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 22, 2005 8:09 AM
To: [email protected]
Subject: MI-L Trim special characters


Is there a command (or function) in MapBasic to trim a special character,
like _? I look through the help, and did not find. Or may be I just passed
it. The LTrim() or RTrim() can only trim space(s).



Jiye Zhang

NYC DEP DWQC Field Operation

(718) 595-6313

(718) 595-6399 (fax)

 <mailto:[EMAIL PROTECTED]/gov> [EMAIL PROTECTED]








***************************************************************************************************
The information in this email is confidential and may be legally privileged.  
Access to this email by anyone other than the intended addressee is 
unauthorized.  If you are not the intended recipient of this message, any 
review, disclosure, copying, distribution, retention, or any action taken or 
omitted to be taken in reliance on it is prohibited and may be unlawful.  If 
you are not the intended recipient, please reply to or forward a copy of this 
message to the sender and delete the message, any attachments, and any copies 
thereof from your system.
***************************************************************************************************

---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 17980

Reply via email to