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
yorcadon
Beginner


Joined: 11 Jun 2009
Posts: 16

PostPosted: Wed Jun 08, 2011 11:40 am   

%expanddb with /class/subclass/@var
 
Basically I am trying to expand a database in a specified class.
The database Test has keys/values (obviously it's just temporary so the key and values don't matter):

test1 1
test2 10
test3 100

It's in the class TestClass and subclass TestSub.
I want it to expand the database that I enter with an alias.
I wasn't able to get it to expand the database just using %1 because I couldn't include the @.
So I just had it assign @%1 to the variable TestTemp. If there is a way to use @%1 in the %expanddb please let me know.

Code:
#VAR TestTemp @%proper(%1)
#ECHO %expanddb(TestClass/TestSub/@TestTemp," ")


I have several different subfolders in that class with identical database names in each, as they're created automatically.
This is what I get when I use the above alias:

TestClass/TestSub/test3=100 test2=10 test1=1

It seems to just pick the first available database by that name, changing the subclass in the alias simply changes the beginning of that output, but the database expanded doesn't change.
Putting the TestClass/TestSub/ before the %expanddb didn't change anything either.
I tried all I can think of and can't find anything in the help files, though I am probably just not looking in the right place.
Is it possible to do this without having to make all the databases with unique names?

Thanks in advance for any and all help.
Reply with quote
yorcadon
Beginner


Joined: 11 Jun 2009
Posts: 16

PostPosted: Wed Jun 08, 2011 12:11 pm   
 
Ok so I kept messing with it and found something that worked.

Code:
#VAR {TestClass/TestSub/TestTemp} @%proper(%1)
#ECHO %expanddb(@TestClass/TestSub/TestTemp," ")


So then I can just put a separate TestTemp variable in each of the subclasses I have, and I can have a separate alias to access each subclass.

If anyone has a better way of doing this, preferably without the whole #VAR mess, I'd love to hear it.
Also is it possible without too much trouble to have the #ECHO list the database in highest to lowest order based on the values, much the same way %sort would list it in order by keys?

Thanks again.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Jun 08, 2011 1:36 pm   
 
Yes, you can use %1 within %expanddb: @{%1}

However, I'm not sure that was your original problem. Try this: %expanddb(@/TestClass/TestSub/%1)

By the way, there is no need to use %proper here--variable names are case-insensitive.
Reply with quote
yorcadon
Beginner


Joined: 11 Jun 2009
Posts: 16

PostPosted: Wed Jun 08, 2011 2:09 pm   
 
That doesn't seem to work. It just displays:
/%1
Where %1 is whatever I happen to type with the alias. Doesn't actually expand anything.

I'm trying to make it so I can have alias1:

Code:
#ECHO %expanddb(@/TestClass/FirstSub/%1)


And alias2:

Code:
#ECHO %expanddb(@/TestClass/SecondSub/%1)


Where both of those subclasses have databases with the same name, but I want to be able to specify which one it looks at.
At the moment it seems to just grab the first one available, ignoring the /path entirely.

If I use the #VAR method I explained in my second post I can at least specify which subclass to use.
However if the database does not exist in the first subclass it just automatically uses another one if available.
I was trying to find a way to tell it to expand the specific database in just one subclass, and ideally do nothing if that database does not exist in that specific subclass.

If I enter the code above right in the command line it works perfectly.
I replace the %1 with what I would enter with the alias and it works great, it doesn't even try to grab a database with the same name from a different subclass.
I put the same thing in the alias and use %1 and it stops working.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Jun 08, 2011 5:13 pm   
 
Another thing you could try is:
%expanddb(@%concat("/TestClass/FirstSub/",%1))

Could you write an alias which simply shows the value of @/TestClass/FirstSub/%1 ? I'm quite certain that should _not_ be defaulting to the first variable that matches %1.
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