|
Htang Beginner
Joined: 20 Mar 2001 Posts: 24 Location: United Kingdom
|
Posted: 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 |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: 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 |
|
|
|
Htang Beginner
Joined: 20 Mar 2001 Posts: 24 Location: United Kingdom
|
Posted: 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! |
|
|
|
Htang Beginner
Joined: 20 Mar 2001 Posts: 24 Location: United Kingdom
|
Posted: 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 |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: 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 |
|
|
|
Htang Beginner
Joined: 20 Mar 2001 Posts: 24 Location: United Kingdom
|
Posted: 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 |
|
|
|
|
|