Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Aekisu
Novice


Joined: 08 Oct 2002
Posts: 34

PostPosted: 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?
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: 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}
Reply with quote
Aekisu
Novice


Joined: 08 Oct 2002
Posts: 34

PostPosted: 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.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net