Jump to content

WriteStringToFile new line


gogutier

Recommended Posts

Probably a noob question but how do I make a new line on a txt file using WriteStringToFile function?

 

I understand it should be with '%r' but it doesn't work. I've tried the excact same example showed on geckwiki and still it does not apply the carriage return, it keeps writing on the same line instead.

 

example: WriteStringToFile "data_file.txt" 1 "Two times four is %g and no more.%rIts name is %n" intVar refVar

 

 

Any help is welcome.

Link to comment
Share on other sites

  • 2 weeks later...

I would do it like this:

WriteStringToFile "data_file.txt" 1 "Two times four is %g and no more." intVar
WriteStringToFile "data_file.txt" 1 "Its name is %n" refVar

or:

aArray = ar_List ("Two times four is " + $intVar + " and no more."), ("Its name is " + (GetName refVar))

forEach aIter <- aArray
    svString = *aIter
    WriteStringToFile "data_file.txt" 1 $svString
loop

 

 

Link to comment
Share on other sites

That's strange. I double checked my code in my previous post, and they both do work as I intended.
The result "data_file.txt" is like this for both code:

Two times four is 10 and no more.
Its name is Bobby Pin
Two times four is 10 and no more.
Its name is Bobby Pin

code:

int intVar = 10
ref refVar = BobbyPin

WriteStringToFile "data_file.txt" 1 "Two times four is %g and no more." intVar
WriteStringToFile "data_file.txt" 1 "Its name is %n" refVar

array_var aArray = ar_List ("Two times four is " + $intVar + " and no more."), ("Its name is " + (GetName refVar))

forEach array_var aIter <- aArray
    string_var svString = *aIter
    WriteStringToFile "data_file.txt" 1 $svString
loop

And interestingly, if I put "%r" on the end of each string data, "data_file.txt" would look like this:

Two times four is 10 and no more.
(empty line)
Its name is Bobby Pin
(empty line)
Two times four is 10 and no more.
(empty line)
Its name is Bobby Pin
(empty line)

code:

WriteStringToFile "data_file.txt" 1 "Two times four is %g and no more.%r" intVar
WriteStringToFile "data_file.txt" 1 "Its name is %n%r" refVar

array_var aArray = ar_List ("Two times four is " + $intVar + " and no more.%r"), ("Its name is " + (GetName refVar +"%r"))

forEach array_var aIter <- aArray
    string_var svString = *aIter
    WriteStringToFile "data_file.txt" 1 $svString
loop

So, seems like "%r" actually does something.

By the way, I use this script function in my mod to store array data to a text file, one array entry per line. If you'd like to check it out. Here is my mod.

Link to comment
Share on other sites

Thanks a lot for your help. I tried directly using your mod (very neat mod btw) and adding items to the custom filter, and it also adds them to the same line! I guess I have some plugin or mod that affects the WriteToFile function in my PC (quite an old one to play FNV, maybe that's related as well).

 

I'll try installing the game in a newer PC and see if somehow that fixes the problem.

Edited by gogutier
Link to comment
Share on other sites

I tried the latest JIP LN NVSE Plugin v56.72 (I was using v56.52), and found that "%r" on WriteStringToFile works as it should.

code:

int intVar = 10
ref refVar = BobbyPin

WriteStringToFile "data_file.txt" 1 "Two times four is %g and no more.%rIts name is %n" intVar refVar

"data_file.txt":

Two times four is 10 and no more.
Its name is Bobby Pin

So, maybe your xNVSE, JIP LN NVSE Plugin and JohnnyGuitar NVSE need to be updated to the latest version?

Link to comment
Share on other sites

  • 3 weeks later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...