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


Joined: 21 Jan 2004
Posts: 4

PostPosted: Wed Jan 21, 2004 8:54 am   

database access
 
how do you get a database variable to actually point to a database?

I have a simple database, 3 fields, I added 3 records to the database to test it. So far every script example, help file and tutorial I have seen returns nothing.

database name is creatures

#dbload cr
#showdb 1

returns 1:

Every other example I have seen returns the same or nothing at all. How do you read/write anything from the database. I have yet to see anything that tells how to point a database variable to a database, just how to create one from scratch that never saves to anything.
Reply with quote
Danlo
Magician


Joined: 28 Nov 2003
Posts: 313
Location: Australia

PostPosted: Wed Jan 21, 2004 10:23 am   
 
Check out the section in the helpfiles, Programming the Database. It tells you all you'll need.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Wed Jan 21, 2004 7:42 pm   
 
I believe that #DBLOAD is part of the database module, which is only in memory when you have a database open. This means you need to open a database with the Database button and leave it open. #DBLOAD can then be used to open additional databases or to select the current database from two or more active databases.

Assuming that you have an open database you can access the current record using the predefined variable %rec.
#SHOWDB %rec

You can also access specific records, by specifying the number, as you did in your own example. However, this will only work if there is actually a record with that number. If you deleted any records their numbers will be skipped, so it is quite possible that you could have three records but no record 1.
Reply with quote
malas
Newbie


Joined: 21 Jan 2004
Posts: 4

PostPosted: Thu Jan 22, 2004 4:59 am   
 
Ok, if dbload requires that you have the databases open, how do you access an existing database without having to keep the database window open all the time?

the examples in the helpfile under programming the database such as

#VAR VarName ""
#ADDKEY VarName Name1 Value1
#ADDKEY VarName Name2 Value2

don't help. This creates an all new database variable with no ties to any existing database. I want to be able to add/edit/remove etc information from a database that I created through the db wizard. How do you do that?
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Thu Jan 22, 2004 11:13 am   
 
Use the same script the DB button uses.
#MENU {Windows|Database}

However, you should give some thought to using the database module the way it's obviously designed to be used. Namely, it's designed to be left open at all times.

I have several characters which use databases and on everyone of those characters I simply leave the databases open. zMUD saves the databases, whether one or several, whenever I close the character using them, and then reopens them automatically whenever I reopen that character. The window itself sits invisibly in the background unless I deliberately bring it to the front. It seems extremely convenient to me, much more so than having to constantly open and close files.

EDIT: Corrected minor typo
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