Archive: max amount of characters that can be written to a file


max amount of characters that can be written to a file
What is the maximum amount of characters that I can write to the Temp file that that was created for me using GetTempFileName command? Here is the code that I wrote to write HTML code to the temp file. When I run my program the HTML page is created, but at some point the text that I write to the file is getting cut off and does not show up in the wcab_forms.html. So I am guessing I hit the limit to the amount of characters that I can write to the file. How can I increase the limit? Thank you.


GetTempFileName $R1 "$INSTDIR\Version 1.2"
ClearErrors
FileOpen $8 $R1 "w"
FileWrite $8 "some HTML code"
FileClose $8
Rename $R1 "$INSTDIR\Version 1.2\wcab_forms.html"


the special builds might at least increase this limit


Thanks, it is still kind of short. I guess I would need to build the web page outside of the installer.


The GetTempFileName Function should only return the name of a file, but should have no bearing on what gets created within the file itself. (In fact, I think you'll find that it's the FileOpen command that actually creates the file, not the GetTempFileName function.)

I'd say your problem is likely that you are trying to write too many charcaters at once. You may need to write to the file with several FileWrite commands strung together.

(I'm not sure what the actual limit is, but since FileRead can only deal with 1024 characters, I'd guess that FileWrite is probably the same.)


Thanks, I will try your suggestion. I will use several FileWrite commands instead of one. For the FileOpen command I would need to use append (FileOpen $8 $R1 "a"), right? So the contents of my 1st FileWrite command would not be erased.


You dont need to open and close the file between writes.
Ex:

FileOpen x abcd
FileWrite x yy
FileWrite x zz
FileClose x


Incidentally if you want to use append, you also have to stick the filepointer at the end of the file:


FileOpen $0 "filename" a
FileSeek $0 "0" end
FileWrite $0 "stuff"
FileClose $0