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


Joined: 20 Mar 2001
Posts: 24
Location: United Kingdom

PostPosted: Thu Jun 12, 2003 1:55 pm   

Database pattern matching
 
Ive done a search on this topic, but can't find anything relevant, so here is my problem/question.

Basically upon entering a room, i strip the items from the room description, replace all the whitespace, ands and thes etc.. and turn them into a string list which then gets sent to an Items window.
I have an item database set up, which as one of the fields includes the value of the item. Note: the items in the stringlist will match exactly the item name in the database.

Is there any way to make the stringlist appear with the items in different colours based upon their value?

All i guess i need is an example of how to reference the Name field of the database, query the value associated with it, and colour the text. Once i know how to do this, i should be able to adapt it to exits and other things.

P.S. I only taught myself how to program the database over the past 2 days.

Thanks MUCH in advance

Htang
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Fri Jun 13, 2003 12:25 pm   
 
Loop through the stringlist and use %query to get the corresponding record for each item in the database. Example:
#FORALL @list {#IF (%query(&Name = "%i")) {#VAR rec %item(%query(&Name = "%i"), 1);#SH The value of %i is %db(%dbget(@rec), "Value")}}

If more that one item have the same name in the database, this script will only return the first item that matches in the database (because of the %item part that only gets the first item in the stringlist returned by %query). For more information look at the help entries for the %query, %dbget and %db functions.

Kjata
Reply with quote
Htang
Beginner


Joined: 20 Mar 2001
Posts: 24
Location: United Kingdom

PostPosted: Sat Jun 14, 2003 12:13 am   
 
Many many thanks for that. I never thought of looping through the stringlist, i was trying to make loop through the database and colour stuff that way.

Well again many thanks!
Reply with quote
Htang
Beginner


Joined: 20 Mar 2001
Posts: 24
Location: United Kingdom

PostPosted: Sat Jun 14, 2003 11:37 pm   
 
Ok, i finally figured out what the problem is. It has nothing to do with what i was writing script wise, its just that i cant seem to reference the database made from one window, in another window. Is there a way to rectify or work around this?
Even a simple #SHOW %dbget doesn't return anything.

Thanks in advance.
Gareth
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sun Jun 15, 2003 2:44 am   
 
Is the other database loaded? Can't do anything to it if it's not loaded, and to do anything to any database you need the DB window opened (though you can hide it so it's out of the way of your playing field).

li'l shmoe of Dragon's Gate MUD
Reply with quote
Htang
Beginner


Joined: 20 Mar 2001
Posts: 24
Location: United Kingdom

PostPosted: Mon Jun 16, 2003 1:53 pm   
 
This is weird and to me seems silly. To be able to populate the database, i have to have the database window open for my main character window.
Then to be able to access this information in my Items window, i have to open another instance of the database, and keep that window open.
In addition the second instance of the database does not update when something changes in the first.

Do I have this correct or am i totally misunderstanding the idea.

Htang
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