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


Joined: 16 Jun 2004
Posts: 6
Location: USA

PostPosted: Tue Nov 16, 2004 9:05 am   

Basic database help needed - can't create multirecord db
 
I'd like to use databases extensively in my scripts but I'm running into a very basic problem that has me stumped. I've ploughed through the forums and can't find another example of the same problem. Examining completed scripts yielded no answers either.

Essentially I can create all the records I want but cannot combine them into a single database.

#ADDKEY dbRecord {Name=Test1|Level=10}
#NEW dbDatabase @dbRecord
#SHOWDB @dbRecord
#SHOWDB @dbDatabase

dbDatabase is empty.

#VAR dbRecord %null
#ADDKEY dbRecord {Name=Test2|Level=20}
#NEW dbDatabase @dbRecord
#SHOWDB @dbRecord
#SHOWDB @dbDatabase

dbDatabase still empty, want to see 2 records in it by now.

Problem may lie with getting the damn thing 'open' but the documentation for that is vague and conflicting. I've played with the DB menu and creating them there but I'm unable to access them with scripts with any of the standard #DBXXXXX commands.

Here's what I'm constructing: A spell queue.

The command to cast a spells loads it in the database and the casting alias can then shuffle order, cancel the whole queue, etc.

I just can't get multiple records added to a single database.

Some sort of through tutorial for generic database utilization would be awesome.

Thanks,
--Ryan
Reply with quote
mortie
Wanderer


Joined: 26 Sep 2002
Posts: 73
Location: United Kingdom

PostPosted: Tue Nov 16, 2004 10:16 am   
 
This exert is taken straight from the finished script section created by the Zmud Guru Troubadour.

Thread -> http://forums.zuggsoft.com/phpbb/viewtopic.php?t=2164

#DBLOAD eq
#NEW All @newRecord
#DBRESET

'eq' is the two letter name for the database and 'All' is the view name.
So for the above example using a database named 'eq' it would be :-

#ADDKEY dbRecord {Name=Test1|Level=10}
#DBLOAD eq
#NEW All @dbRecord
#DBRESET eq

If you have more than one database then refer to it's database name.

#NEW All|eq @dbRecord

You can find a lot of info in past threads. It takes a little time to trawl through them but its worth the effort.
Reply with quote
rccola
Newbie


Joined: 16 Jun 2004
Posts: 6
Location: USA

PostPosted: Wed Nov 17, 2004 8:53 am   Database help -- unable to create a multirecord db
 
I've spent a couple hours browsing the forum before asking and I'd tried your suggestion before. Troubadour's post was one of the first I found and it's excellent. It concentrates on creating an eq database and very little had much bearing on my problem as when I replicated just his db code it didn't work. However, I restested your code exactly as typed and got the same results.

#ADDKEY dbRecord {Name=Test1|Level=10}
#DBLOAD db (or dbDatabase)
#NEW All @dbRecord
#DBRESET (syntax error with #DBRESET db, command doesn't take an argument)
#SHOWDB @dbRecord
#SHOWDB @dbDatabase
#SHOWDB @db

Both db and dbDatabase continue to be empty. #NEW appears to do absolutely nothing. I can play around with different entries and nothing changes. I'm using 7.05.

Thanks for the fast response. Hope you can offer more insight.

--Ryan
Reply with quote
mortie
Wanderer


Joined: 26 Sep 2002
Posts: 73
Location: United Kingdom

PostPosted: Wed Nov 17, 2004 9:12 am   
 
Sorry for the mistake in the #DBRESET.

Just a thought, do you have the corresponding fields in the DB labled as Name and Level?

Try this command

#LOOPVIEW {#SHOW &Name,&Level}

This will loop through the current database displaying each record with the fields Name and Level.

#SHOWDB is used to display one record at a time.
Reply with quote
rccola
Newbie


Joined: 16 Jun 2004
Posts: 6
Location: USA

PostPosted: Wed Nov 17, 2004 9:57 am   
 
In all of my travels I havn't found any reference to anything MORE than the code you've listed. Corresponding fields implies there's something else one must create.

I don't want a saved database, all my potential applications are for session specific databases.

Thanks,
--Ryan
Reply with quote
mortie
Wanderer


Joined: 26 Sep 2002
Posts: 73
Location: United Kingdom

PostPosted: Wed Nov 17, 2004 11:59 am   
 
I see, you didn't make it clear that you didn't want a 'saved' database. Which i assume means you haven't manually created a database via the GUI and created fields for it?
Thats why the examples above aren't working. As for as im aware you can't create a zmud database via code on the fly. You have to manually create it and have the database open to work with
it. There are ways to do this via an external database program which uses the Jet database format but not really worth it for what you want.

I think you have a couple of options to proceed with this.

1) Either you create a database with required fields and use this. If you want to discard all the records at the end of the current session you could wipe it.Thus leaving a blank db ready for the next session.
2) Or depending on the amount of info you have, do away with a database and just use a data record.
Reply with quote
rccola
Newbie


Joined: 16 Jun 2004
Posts: 6
Location: USA

PostPosted: Thu Nov 18, 2004 6:42 am   
 
THAT was the little detail I was missing. Why in the *%&*&^#$ does the documentation for #DBLOAD not mention these things for crying out loud?

That and you can't have a variable the same name as the database.

Another missing detail I had to dig outta the forums was that the key for a particular record is accessed by the name 'Num'. ie. %rec.Num

I have my queue implemented and it works great. Thanks so much for your assistance!
--Ryan
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