ID:266376
 
I have a few questions about text files within BYOND:

- How do you create one? New("Text.txt") does not seem to work.

- How do you create a hard enter in a text file? Does \n do it?

Thanks for your time.

-Lord of Water
- How do you create one? New("Text.txt") does not seem to work.

var/file/textfile = file("text.txt")
Will, I believe, do it. You can then do
textfile << "Blah"
to append "Blah" onto the end of the file.

If not, there's a text2file() (and matching file2text()) proc that you should look into.

- How do you create a hard enter in a text file? Does \n do it?

Yes.

-AbyssDragon
In response to AbyssDragon
Ahh crap, I've been doing the whole ImportText ExportText thing and I could have just been doing src << file2text("desc.txt"). I wish someone would have pointed this out to me earlier! :oP

So...anyone know of any advantages of one over the other? Besides ImportText being able to have multiple descriptions from the same file?
In response to Foomer
ImportText and ExportText are specifically for changing savefiles into a human-readable format (and back again). I'm not even sure how you'd go about using them for general text-file manipulation...

-AbyssDragon
In response to AbyssDragon
I may be doing something completely wrong here, but I get compiled problems:
proc/Save()
var/file/T = file("FlashCards -- \[[CardsName]].txt")
text2file("Hello/nHello",T)

Gives me the following errors:

FlashCard Maker.dm:44:error:T:undefined type: T
FlashCard Maker.dm:43:T :warning: variable defined but not used

It would seem to me that I did define T, and that T is used. Am I wrong? Am I using text2file() or file() incorrectly?

Thanks again.

-Lord of Water