Information générale
Catégorie:
Codage, syntaxe et commandes
>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"
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement