Skip to content
⌘ NSIS Forum Archive

Write to text File

5 posts

folly#

Write to text File

Apologies for this distraction. I ve searched the forum and read various tutorials but no clue.
I want to send some strings to a text file. if the file does not exist at the desired destination, then create it.
some of the text should be tab or comma separated in order to be read by an application.
e.g
"My Name " + tab separation + " This is just a test"
"My Address " + tab separation + " My address is not yet known"
etc

Any clue will be appreciated
JasonFriday13#
FileOpen, FileWrite, and FileClose in chapter 4.9.5 File Instructions of the NSIS manual should do the trick quite nicely. To use a tab in your string, put $\t where you want it.
folly#
the tab symbol is not working pls. pls advise on usage

"Report_Directory $\t $R0/Report"

where $RO is the directory variable

Thnaks upfront
JasonFriday13#
This test code:

Name "j"
OutFile "File Write Test.exe"

Page instfiles
ShowInstDetails show

Section
FileOpen $0 "$DESKTOP\hello.txt" w
FileWrite $0 "Hello.$\tThis is tabbed.$\tTry and catch me.$\r$\nHello again.$\tTab.$\tTab.$\tTab."
FileClose $0
SetAutoClose false
SectionEnd
yields this output in hello.txt:

Hello. This is tabbed. Try and catch me.
Hello again. Tab. Tab. Tab.