Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Belariad
Newbie


Joined: 04 Feb 2007
Posts: 9

PostPosted: Sun Feb 15, 2009 9:14 pm   

Omitting fields from a database
 
Is there any way using the #SHOWDB command or any other way to display database records, but omit the fields that have no data in them? There are a lot of possible fields that different items in my mud can have, but an item usually only has 5 or 6 most of the time. So i am simply trying to avoid having a huge list of 50 fields show up when each item only usually has at most 10 of those.

The only method of limiting database information i've found so far is by using views, but there's really no one type of item that only has certain modifiers. Items in my mud can have almost any modifier, so there's no real effective way of using views for my intended purpose.
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Sun Feb 15, 2009 9:30 pm   
 
I think #loopdb would work with %rec, so in theory you could do:

#loopdb %rec {#if (%val != %null) {#print %key = %val}}

I don't really have a good database at the moment, though, so this is completely untested.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5187

PostPosted: Sun Feb 15, 2009 9:40 pm   
 
Using #LOOPDB and an #IF would normally be the way it is done. If your database has many fields %subregex might be able to handle it faster.

I don't really recommend using %subregex for manipulating record variables because of the overheads of converting the hash table to a string and then back to a hash table. However if you preformat the string for display with %expanddb then some better speed gains can be realized.

A subregex that should strip keys that have a null value from a record variable would be:
%subregex(@recordVar,"(?:^|\|)[^=]+=(?=\||\z)","")
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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