ID:142429
 
Code:
encrypted_save
proc/Decrypt()
var/file_text = file2text("[name]")

if(decrypt_reference && decrypt_method) file_text = call(decrypt_reference, decrypt_method) (file_text, key)
else if(decrypt_method) file_text = call(decrypt_method) (file_text, key)

fdel("[name]")
savefile = new(name)
savefile.ImportText(file_text)

world << file_text
world << savefile.ExportText()

name = savefile.name

dir = savefile.dir


Problem description:
I'm currently in the process of rewriting my pif_EncryptedSave library, and I'm nearly complete. Problem is, something seems to be up with savefile.ImportText(). With those bits of output, I get the following:
age = 20
full_name = "John Doe"
height = "5'6\""
weight = "120 lbs"
key = "The Fizz Meister"
ckey = "thefizzmeister"


\nage\ \=\ 20\nfull_name\ \=\ \"John\ Doe\"\nheight\ \=\ \"5\'6\\\"\"\nweight\ \=\ \"120\ lbs\"\nkey\ \=\ \"The\ Fizz\ Meister\"\nckey\ \=\ \"thefizzmeister\"\n


I'm running this off the demo code, and I'm using Air Mapster's (Mike H's) RC5 library for it. I can't figure out why savefile.ImportText() is causing that. As you can see, somehow everything is getting escaped.
Well, that's not quite like the example in the reference. Close, though. Even so, I can't think why it would display like that. Maybe try something a little more like this?

[file2text(txtfile)]


Also, why are you naming your savefile "savefile"? Isn't that a reserved word?
In response to Xooxer
You don't need a file to use /savefile.ImportText() or /savefile.ExportText() both, as stated in the reference, can use a string if no file is listed, and the arguments aren't required to be in that order (which are only two of several like that). I also changed the name of the variable from savefile to save in the off-chance that that somehow caused the problem, which it didn't.
So, does anyone have the vaguest idea on what's going wrong here, or will I have to create my own version of ImportText()
Popisfizzy wrote:
Code:
>       savefile.ImportText(file_text)


Instead of savefile.ImportText(file_text), try savefile.ImportText(savefile.cd, file_text). I think that should do it.
In response to Kuraudo
Ah, it seems you have to include the directory when using ImportText(), which is weird, seeing as how you don't for ExportText(). Thanks. =)