Tracy Pearson wrote:
> Have a look here:
> http://fox.wikis.com/wc.dll?Wiki~BaseX
>
>   

Too Late! 

**********************************************************************
* Function...: CleanOctal
* Author.....: Vincent Teachout
* Date.......: May 03, 2007, 13:15:27
* Notice.....: Copyright © 2007, Caracal Software.
* ...........: All Rights Reserved.
* Purpose....: Convert octal codes within a given string to ascii code
*              Code MUST be in format \999.  eg. \046
*            : Example: ? CleanOctal("Bob \046 Mary") && "Bob & Mary"
* Parameters.: cString
* Returns....: New string with octal codes converted to ascii
* Compiler...: Visual FoxPro 09.00.0000.3504 for Windows
**********************************************************************
FUNCTION CleanOctal
LPARAMETERS cString

    LOCAL nI, nJ, nCount, cSub, cReplace
   
    * Work backwards - we'll be modifiying the string on the fly, 
efectively removing one "\" each time
    nCount = OCCURS("\",cString)
    FOR nI = nCount TO 1 STEP -1 
       
        cSub = SUBSTR(cString, AT("\",cString, nI), 4)  && Get last 
(rightmost) occurance and following three chars
        lIsValid = .T.  && assume is valid format
        FOR nJ = 2 TO 4 
            IF ISDIGIT(SUBSTR(cSub,nJ,1)) = .F.  && Note: No harm done 
if we attempt access an out of range substr - ie, 3rd char of a length 2 
string
                lIsValid = .F.
                EXIT
            ENDIF
        ENDFOR

        IF lIsValid = .T.  && In correct format for Octal conversion
          nAscii = 0
            nAscii = nAscii + VAL(SUBSTR(cSub,2,1))* 8^2
            nAscii = nAscii + VAL(SUBSTR(cSub,3,1))* 8^1
            nAscii = nAscii + VAL(SUBSTR(cSub,4,1))* 8^0   

            IF nAscii <256
                cReplace = CHR(nAscii)
                cString = STRTRAN(cString, cSub, cReplace)
            ENDIF
           
        ENDIF
   
    ENDFOR


RETURN cString
ENDFUNC


-- 
Vince Teachout
Caracal Software
www.caracal.net
518-733-9411



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/%(messageid)s
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to