|
kilpher Newbie
Joined: 26 Dec 2005 Posts: 5
|
Posted: Fri Sep 12, 2008 5:40 am
Database Looping Problems |
I have a database of spells I use for spelling up my character. In it, I add and remove spells (IsCast = True/False) based on triggers from the mud. I have a respell alias that when I type it loops through the db and casts anything where IsCast = False. It's worked perfectly in zMud for years and to imported into cMud without triggering any errors or warnings, but it doesn't actually work in cMud.
Single commands, like the following, work just fine:
#DBPUT %query(&SpellName = @SpellToFind) IsCast True
Commands relying on loops through the database do not:
#LOOPVIEW {#IF (&IsActive = True) {#IF (&IsCast = False) {c '&SpellName'}}
and
#DBFIRST;#WHILE (!%null(%rec)) {#DBPUT %rec IsCast False;#DBNEXT}
both fail. The #LOOPVIEW doesn't even look like it tries. It takes nearly no time to do nothing. The while loop actually looks like it's doing the loop, as it takes time and indicates that's it's busy; it just never actually succeeds on the #DBPUT.
Another oddity: If I type #VIEW at the command line, I get the expected results of a list of all the entries in my database. However, if I do a #LOOPVIEW {#SHOW &SpellName}, I get nothing output.
Ideas?
Kilpher |
|
|
|
Scotadi Newbie
Joined: 27 Sep 2008 Posts: 1
|
Posted: Sat Sep 27, 2008 6:41 pm |
I'm seeing this too.
#LOOPVIEW { #SHOW &name }
does nothing. If I try including the view explictly:
#LOOPVIEW friends { #SHOW &name }
I get ten or so lines (which is not related to the number of items in the view):
friends
friends
friends
....
The lines contain whatever string is in the "view" slot of the command whether it is a real view or not.
#SHOW %count(name, friends) returns the correct count.
The db is loaded according to the database button...
And I'm using vista in a non-admin account
Any help or suggestions? |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sat Sep 27, 2008 8:51 pm |
My apologies for not replying sooner. Some how this topic got lost and I never noticed it.
I hate to say it, but the entire database system in CMud is directly ported from zMud. This was done to provide compatibility with zMud while CMud devlopped and grew. Like the mapper this type of porting caused some things to break.
Zugg is currently working on rewriting the mapper. It generally is used more then the database, and a recent poll overwhelming established it a higher priority. The database code from zMud has many sever limitations, and was written close to 10 years ago. Even during various zMud beta cycles Zugg's interest in improving the database system was often claimed as unnecessary by users. Rewriting the database code is on Zugg's list of things to do for CMud, and when it is time to do that I don't think he will let various user sidetrack him from it.
The best thing I can suggest right now it to use record variables instead of the database. A database is meant to be a collection of records, where each record has some unique field+value and all the other field+values are related. Fields are a category of information, and values are actual information. Databases are designed to have groups of records where the fields are the same and the values change with each record.
The descriptions provided in both posts seem to indicate a single field and value pairing. This sort of multiplicity of fields is better handled by a record variable then a database. I would suggest looking at the commands #LOOPDB, #ADDKEY, #DELKEY; and the function %db in the help. |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
kilpher Newbie
Joined: 26 Dec 2005 Posts: 5
|
Posted: Wed Oct 08, 2008 5:39 am |
Thanks for you post, Vijilante. I'm *somewhat* glad to hear it's an identified bug and I'm not just looking for my glasses on my face.
Maybe I'm just dense, but I'm not visualizing how to use a key/value pair to check more than one attribute at a time to return a value - &IsActive AND &IsFalse. If you can help me there, you can probably skip the rest of this note.
More about current state:
My actual db is a little more complicated than my example. The db contains all player enhancing spells in the game and a few columns to indicate whether they are active (currently available to my class and level), cast (no point in recasting spells I'm already affected by), allowable during combat, castable on others, etc. I also have a priority field that allows me to adjust the order (SQL equiv would be ORDER BY Priority ASC) in which I want to cast the spells regardless of the order of the records in the database (stat enhancing spells with 1 stat driver before stat enhancing spells with multiple stat drivers before non-stat enhancing spells, for example). This priority also allows me to tinker with the order on the fly without rewriting a single line of code.
As an example, I have an alias for respelling myself:
#VIEW All
#LOOPVIEW {
#IF (&IsActive) {#IF (&IsCast = False) {c '&SpellName'}}
#WAIT 10
}
I also have one for spelling up other people:
#VIEW All
#LOOPVIEW {
#IF (&IsActive) {#IF (&OtherCast = True) {c '&SpellName' %1}}
#WAIT 10
}
All in all there are seven related fields all driving different versions of spellups, which is why I chose the format I did. I've been meaning for years to get off the Zmud db and move to something else (cause what zMud calls a db, I call a table and I would like to have several fact/dimentional entities going at once like eq, spells, game stats, etc.). Any suggestions on commands to look up in help to be able to read/write from an external db (I have SQL Server 2008 and Oracle 10G loaded locally and am very comfortable with both - could also go to an ADO/jet based though my skills are a little dated there)?
Thanks again,
Kilpher |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Wed Oct 08, 2008 5:15 pm |
Quote: |
I'm not visualizing how to use a key/value pair to check more than one attribute at a time to return a value - &IsActive AND &IsFalse.
|
Very narrowly defined example, as I'm stepping out the door pretty much right now:
#if (@dbvar.isactive and @dbvar.isfalse) {both are true} {one or both are false} |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
|
|
|
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
|
|