open txt file from wrs ressource and change it

Posted By: Benni003

open txt file from wrs ressource and change it - 03/18/12 16:32

Hello, please help me in something.
I want to load and read a text file wich is packed into a wrs ressource. After this I want to write some variables into it and save it. Could someone give tell me wich commands I hove to write to do this?
Posted By: Widi

Re: open txt file from wrs ressource and change it - 03/18/12 17:32

Manual --> Engine Funktionen --> Datei Funktionen

There are all commands for file manipulation.

PS: Das hättest du auch selber finden können, oder nicht? wink
Posted By: Benni003

Re: open txt file from wrs ressource and change it - 03/18/12 18:12

Hello Widi, I know the commands for file manipulation. My problems are:
How to open a textfile wich is packed into a wrs file and how to save it into this wrs file.
Thank you.

Ja, bevor ich hier etwas schreibe schaue ich natürlich im Handbuch nach wink
Posted By: Aku_Aku

Re: open txt file from wrs ressource and change it - 03/18/12 18:24

add_resource in the Manual.
Posted By: fogman

Re: open txt file from wrs ressource and change it - 03/18/12 18:36

You can´t save to wrs at runtime. You have to copy the file via file_cpy out of the wrs, then you can alter it and save it. The engine will use this file from now on, not the one in the wrs. However, it´ll be visible to everyone, then.

Maybe you can encrypt it.

Manual (@file_cpy)
Quote:

For copying a text file from a .wrs resource, rename the file to "*.pak" and add it to the resource with a BIND statement in a .wdl file, or a PRAGMA_BIND in a .c file (f.i. #define PRAGMA_BIND "mytext.pak";). At runtime, copy the text file from the resource with file_cpy("mytext.txt","mytext.pak");. The resource must either exist in the work folder, or be opened by add_resource.

Posted By: Benni003

Re: open txt file from wrs ressource and change it - 03/18/12 19:59

ok, thank you guys. I will do it in an other way without wrs. file laugh
Posted By: Benni003

Re: open txt file from wrs ressource and change it - 03/18/12 22:09

Now it's good working:) Here how I did it:

file_cpy("test.txt","test.pak");

var status_file = file_open_read("test.txt");

v_mission=file_var_read(status_file);

file_close(status_file);

file_delete("test.txt");

the file "test.pak" is packed into a wrs file.
© 2023 lite-C Forums