Information générale
Catégorie:
Codage, syntaxe et commandes
>I am writing to a binary data stream using CHR(#). ie lcdata = CHR(1) + CHR(10) + CHR(12). When the number 10 comes up I output CHR(10). When I look at the file there is a CHR(13) directly in front of the CHR(10). Anyone know how to prevent this from happening?
>
>I am running VFP6 on NT.
>
>Another person and I ran the following test:
>
>>>n=fcreate("test.tmp")
>>>?fwrite(n,chr(1))
>>>?fwrite(n,chr(10))
>>>?fwrite(n,chr(12))
>>>?fwrite(n,chr(1))
>>>?fwrite(n,chr(10))
>>>?fwrite(n,chr(12))
>>>?fclose(n)
>>>do sys(2004)+"tools\hexedit\hexedit" with "test.tmp"
>>>
>>>HexEdit shows only 6 bytes in the file:
>>>0x01 0x0A 0x0C 0x01 0x0A 0x0C
>
>This is what I have after running the same test test:
>
>0x01 0x0D 0x0A 0x0C 0x01 0x0D 0x0A 0x0C
My guess is that the chr(13) is added by the editor you use to see the file in the second test. In case you use modi comm or modi file, go to the Edit/Properties menu option and uncheck the "Save with line feeds" option.
The way you write to the file is correct, as proved by the hex editor.
Vlad
Précédent
Suivant
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