|
Anaristos Sorcerer
Joined: 17 Jul 2007 Posts: 821 Location: California
|
Posted: Tue Dec 18, 2007 12:12 pm
CMUD 2.18 problem in creating DB. |
The following code worked fine in CMUD 1.34
Code: |
#DBLOAD @MapDB
#LOOP %numrooms() {
#VAR mapvnum {%mapvnum( %i)}
#IF (!%null( %roomname( @mapvnum))) {
#VAR query {%query( &RoomName = %roomname(@mapvnum), All)}
#IF (!%null( @query)) {
#VAR dbrec %dbget(@query)
$count = &RoomCount
$index = &RoomVnum
#IF ($count = 1) {$index = %arrhigh(ArrayMDB);#UNVAR list;#ADDITEM list &RoomVnum;#CALL %arrset(ArrayMDB,$index,@list)}
#VAR list %arrget(ArrayMDB,$index)
#ADDITEM list @mapvnum
#ADD $count 1
#CALL %arrset(ArrayMDB,$index,@list)
#DBPUT @query RoomName %roomname( @mapvnum) RoomVnum $index RoomCount $count
} {#NEW "" RoomName=%roomname( @mapvnum) RoomVnum=@mapvnum Roomcount=1}
}
}
|
New it just creates blank records which happens because the #NEW command adds blank records so the %query will always fail.
Now I am not in love with this code, I ran it because it worked before and I wanted to see how it would work under 2.18. I was going to test if, in fact, the arrays were persistent.
I tried adding records manually to the DB using #NEW. No matter what the parameters are, the record stored is blank.
Now when I ran this code in 1.34, it stuffed records for over 5 hours without missing a beat. (I know, it's aweful and unecessary, but good excercise for the platform).
This is a modification of a code I found on the zMUD forum. It didn't work properly because it tried to store string lists in the DB records. Somtehing not allowed. Instead, I tried storing the data in an Array, but arrays weren't persistent in 1.34. So the code had little value then but I expected arrays to be persistent in 2.xx, so I gave a the code a try. The result is that it does nothing in 2.18 except create blanks records. |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Tue Dec 18, 2007 3:45 pm |
I don't see a problem with #new. I can successfully create new records with #new, both manually and in a trigger. You say you when you did it manually it made blank records? Could you show exactly what you typed that made blank records?
|
|
|
|
Anaristos Sorcerer
Joined: 17 Jul 2007 Posts: 821 Location: California
|
Posted: Wed Dec 19, 2007 4:36 am |
I typed
Code: |
#DBLOAD xx
#NEW "" RoomName=test RoomVnum=1 Roomcount=0
|
also tried
Code: |
#DBLOAD xx
#NEW "" {RoomName=test|RoomVnum=1|Roomcount=0}
|
Remember, the code in my original note worked fine in 1.34. For my map database of about 25000+ rooms, this code runs for about 5 hours without a hitch. I didn't touch it. I just ran it after upgrading. It now only produces blank records. |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Wed Dec 19, 2007 4:59 am |
Might I ask what are you really trying to do with this database?! I realize there is likely a bug with #NEW, and it is a total dodge to say let's just not use the bad DB module that desperately needs to be rewritten. Still it stands to reason that if you are doing something with the map which is already a database it might just be better to use a different solution.
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Wed Dec 19, 2007 2:44 pm |
Vijilante is probably right, there is probably a way to use the mapper database directly to do what you ultimately want. I am bothered by your problem with #NEW. I've created a database with RoomName, RoomVnum, and RoomCount, and used your commands. It properly adds fields to my database. I don't see why yours is not working, but I'll keep thinking about it.
|
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Jan 07, 2008 9:52 pm |
Try putting " quotes around the second argument to #NEW like this:
#NEW "" "RoomName=test|RoomVnum=1|Roomcount=0"
or in your original script, instead of:
#NEW "" RoomName=%roomname( @mapvnum) RoomVnum=@mapvnum Roomcount=1
use this:
#NEW "" %concat("RoomName=",%roomname( @mapvnum)," RoomVnum=",@mapvnum," Roomcount=1")
or you might try:
#NEW "" %concat("RoomName=",%roomname( @mapvnum)) %concat(" RoomVnum=",@mapvnum) " Roomcount=1"
and see if that helps. I think the problem is that the Database module is old (directly ported from zMUD) and doesn't know how to handle the new string list hash table properly. So you need to pass a literal string value to the database module for it to parse it correctly. It certainly isn't going to parse the = in the command without it being within some kind of quotes. |
|
|
|
|
|