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
soljax
Newbie


Joined: 18 Sep 2002
Posts: 4

PostPosted: Wed Sep 18, 2002 3:23 am   

How do you reset the database REC counter?
 
I started fiddling around with the database. For the life of me I can't figure out how to restart the database "REC" counter. This causes all sorts of problems for my script, because I've deleted the first 80 ish entries.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Wed Sep 18, 2002 5:35 pm   
 
1. Backup the current database
2. Export the current database
3. Create a new database
4. Import the data from step 2
5. If successful, you can delete the current database and use the new one

LightBulb
Senior Member
Reply with quote
Charbal
GURU


Joined: 15 Jun 2001
Posts: 654
Location: USA

PostPosted: Wed Sep 18, 2002 7:36 pm   
 
I can't really think of a reason you should need to restart the record counter in the database. In general, making a script that relies on the numbering being contiguous and starting from 0 is not a good idea as it can cause problems as you have found out. Instead, you can use commands like #DBFIRST, #DBNEXT, #DBPREV and #LOOPVIEW. For database functions/commands that require a record number, get the record you want in %rec and then use %rec.Num or &Num instead.

For example, to show the Name field of every database record, instead of

#LOOP 0,%numrec() {#DBGET %i;#SHOW &Name}

which is dependent on the numbering of the database, you could use

#DBFIRST;#WHILE (!%null(%rec)) {#SHOW &Name;#DBNEXT}
or simply
#LOOPVIEW {#SHOW &Name}




 - Charbal
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