|
Aekisu Novice
Joined: 08 Oct 2002 Posts: 34
|
Posted: Thu Sep 25, 2003 1:25 am
File write and read |
I'm finding the file commands (open, read, and write) confusing, especially since they seem to be designed to handle text rather than integer values.
What I want to do is to save the total number of kills during a session. Then I log back on to my mud, I want to access that information and be able to add to it when I log off. The idea is to keep a running total.
The docs seem to indicate there is a random file access function. It would seem I should be able to read and write to the same file location to store my running total of kills but all I get is junk.
Can someone help me out here by giving an example of how the code should look? |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Thu Sep 25, 2003 6:41 am |
There is no "open" command. Files are opened with the #FILE command.
Yes, they are all text files whether they are sequential or random access.
There's no need for a file to save a single value. Just use variables. A variable's current value is saved whenever the settings are saved, which most people do when they close the window (automatically by default). When the window is reopened, the variable is reloaded with the last saved value unless it has a default value.
#AL atdisconnect {#ADD totalkills @sessionkills;#VAR sessionkills 0} |
|
|
|
Aekisu Novice
Joined: 08 Oct 2002 Posts: 34
|
Posted: Thu Sep 25, 2003 9:08 am |
Ya, I'm know about #file. Coming from a C background, open just comes naturally.
I sure appreciate the help. Your example will take care of my problem. |
|
|
|
|
|