Archive: Not able to write to a text file


Not able to write to a text file
Hi all,

Below is a piece of code in my installer code

Page custom myFunc2

Function myFunc2

MessageBox MB_OK "$INSTDIR: hello"
${WriteToFile} "hello" "$INSTDIR\Install.txt"

FunctionEnd


My WriteToFile function works properly in several other places of the code. However in myFunc2; the messagebox display works fine but the WriteToFile doesn't create any "Install.txt" in the $INSTDIR folder.

I am unable to figure out any problem here. Please advice the possible reasons?


Could you try this?

Function MyFunc2
FileOpen $0 "$INSTDIR\Install.txt" w
FileWrite $0 "hello"
FileClose $0
FunctionEnd

Nope both dont seem to work. I have already tried the two ways. However I have a feeling that I am doing something wrong in the function Example1 which is called just before myFunc2 is called. Below are the codes for both Example1 and myFunc2.

Note that the WriteToFile used in Example1 is working perfectly fine. But the WriteToFile in myFunc2 doesnt generate any new text file although the parameters $R0;$R1;$R2 display the correct values in the message box.


Function Example1

${DriveSpace} "$9" "/D=T /S=G" $R0${DriveSpace} "$9" "/D=O /S=G" $R1
${DriveSpace} "$9" "/D=F /S=G" $R2

Push "Total space of $9 ($8)drive is : $R0 GB $\r$\n \
Occupied Space of $9 ($8) drive is : $R1 GB $\r$\n \
Free Space of $9 ($8) drive is : $R2 GB"

Push "$INSTDIR\SystemConfig.txt"
Call WriteToFile
Push $0
FunctionEnd

Function myFunc2

${GetSize} "..\Package Files" "/M=*.* /S=0B" $R0 $R1 $R2
MessageBox MB_OK "$INSTDIR: $R0 : $R1 : $R2"
${WriteToFile} "hello" "$INSTDIR\Install.txt"

FunctionEnd

Please advice. Thanks a lot for the help.


Why not use ${WriteToFile} in Function Example1?
Also, what is the Push $0 for?

Stu