Sign in to follow this  
Followers 0
NerdFencer

Null and cr cut out in file write

3 posts in this topic

#1 ·  Posted (edited)

I have this as the only line of code that writes to this particular file...

FileWrite("Working\Resources\war3map.imp",$file&Chr(0)&Chr(13))

the Null [Chr(0)] and cr [Chr(13)] chars don't end up in the end file

(and yes, i have tried it with the @CR macro)

I dont see what is wrong, I just cant get the chars to write!

Can someone explain what is wrong, or lacking an explanation, another way to accomplish the task that works?

Edit:

Added source

Resource_Inliner.au3

Edited by NerdFencer

_________[u]UDFs[/u]_________-Mouse UDF-Math UDF-Misc Constants-Uninstaller Shell

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

To write Null char the file must be open in binary mode before writing.

and it's better to always use this form when writing/reading file

FileOpen ( "filename", mode )

"filename" = Filename of the text file to open.
"mode"   = Mode (read or write) to open the file in.
             Can be a combination of the following:
             0 = Read mode
             1 = Write mode (append to end of file)
             2 = Write mode (erase previous contents)
             4 = Read raw mode
             8 = Create directory structure if it doesn't exist (See Remarks).
            16 = Force binary(byte) reading and writing mode with FileRead and FileWrite
            32 = Use Unicode UTF16 Little Endian reading and writing mode. Reading does not override existing BOM
            64 = Use Unicode UTF16 Big Endian reading and writing mode. Reading does not override existing BOM
           128 = Use Unicode UTF8 reading and writing mode. Reading does not override existing BOM
             Both write modes will create the file if it does not already exist.
             The folder path must already exist (except using mode '8')

$handle = FileOpen("path_to_your_file_to_open")
FileWrite($handle, "some text")
FileClose($handle)oÝ÷ Ù*-¯+aȧ¶¨º»®*mjÆ«zZqéÖ®¶­sdgVæ2fÆTFBb33c¶fÆR¢b33c¶öfÆSÔfÆT÷VâgV÷Cµv÷&¶ærb3#µ&W6÷W&6W2b3#·v#6Öæ×gV÷C²Ã³b²÷""³bFòW&6R&Wf÷W2fÆR6öçFVç@¢fÆUw&FRb33c¶öfÆRÂb33c¶fÆRf×´6"f×´6"2¢fÆT6Æ÷6Rb33c¶öfÆR¤VæDgVæ
Edited by taz742

Share this post


Link to post
Share on other sites

To write Null char the file must be open in binary mode before writing.

and it's better to always use this form when writing/reading file

Thank you, it worked :)

_________[u]UDFs[/u]_________-Mouse UDF-Math UDF-Misc Constants-Uninstaller Shell

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0