Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Replace chr(2) & chr(1)
Message
From
02/04/2012 15:06:43
 
 
To
02/04/2012 12:36:45
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01540029
Message ID:
01540047
Views:
55
>I have some text that I converted to ascii to see what character codes were in it so I could replace them
>
>the text is
>
>April 9th Program materials
>
>the Ascii code converts to this
>65 112 114 105 108 32 57 116 104 32 80 114 111 103 114 97 109 32 109 97 116 101 114 105 97 108 115 2 1
>
>when I try m.des1=STRTRAN(description,CHR(2)+CHR(1),'') it does not replace the characters
>with a space.
>
>I need this and other information to be on one line.
>any suggestions?

Your code would replace specifically the sequence CHR(2) followed by CHR(1) with space. Perhaps you meant to replace occurances of CHR(2) and CHR(1) with space? That would be:
des1=CHRTRAN(description,CHR(2)+CHR(1)," ")
* Above code replaces CHR(2) with space, CHR(1) with space

Newlne sequence is usually CHR(13) followed by CHR(10) (though in some contexts just a CHR(13) or CHR(10) would act as newline) -- so you could code:
des1=CHRTRAN(description,CHR(13)+CHR(10)," ")
* Above replaces CHR(13) and CHR(10) with space

Just in case you weren't sure about functionality difference between CHRTRAN() and STRTRAN()

? CHRTRAN("ABCDCBA A-B-C", "ABC", "123")
returns
123D321 1-2-3
&& does the following: 'A'-->'1', 'B'-->'2', 'C'-->'3'

and with STRTRAN()

? CHRTRAN(*"ABCDCBA A-B-C", "ABC","123")
returns
123DCBA A-B-C
* replaces "ABC" with "123"
Previous
Reply
Map
View

Click here to load this message in the networking platform