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
Lasivian
Wanderer


Joined: 25 Jan 2002
Posts: 76
Location: USA

PostPosted: Mon Sep 21, 2009 4:00 pm   

Comparing a string to a database record - Solved
 
I'm trying to just make a "list" of known items and compare a string against each item on the list. If someone has a simpler way to do this please let me know.

I'm figuring comparing against a databse is easiest, but it's not working right.

I'm using:

Code:
#TRIGGER {^*gives you (*).$} {#DBFIRST;#WHILE (!%null(%rec));#IF (%1 = &name) {put &keyword in @container}{#DBNEXT}


Echos are showing me the item name and the database field to compare to are correct but somehow the comparison isn't happening, I assume i'm missing something someplace.

Thanks


Last edited by Lasivian on Wed Sep 30, 2009 3:50 pm; edited 1 time in total
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Mon Sep 21, 2009 5:58 pm   
 
Try quoting the if statement like so.

Code:
#IF ("%1" = "&name")
_________________
Asati di tempari!
Reply with quote
Lasivian
Wanderer


Joined: 25 Jan 2002
Posts: 76
Location: USA

PostPosted: Mon Sep 21, 2009 8:39 pm   
 
"%1" = "&Name" - The script always thinks it has failed to make a match
"%1" =~ "&Name" - The script always thinks it has made a match

#Echo shows the strings are exactly identical.

Code:
#DBLOAD Fishing.db
#DBFIRST
#Echo I was given %1
#LOOPVIEW {#IF ("%1" = "&Name") {#Echo Database shows '&Name', Item is '%1'\#Echo Putting &keyword in @fishingcontainer\put &Keyword @fishingcontainer\#DBNEXT} {#Echo Database shows '&Name', Item is '%1'\#Echo Item not put in container\#DBNEXT}}


Thanks alot for all your help btw :)
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Tue Sep 22, 2009 3:07 am   
 
Not sure why that's not working... try the %regex or the %match functions instead.
_________________
Asati di tempari!
Reply with quote
Lasivian
Wanderer


Joined: 25 Jan 2002
Posts: 76
Location: USA

PostPosted: Wed Sep 30, 2009 3:50 pm   
 
Solved it, this works perfectly:

Code:
#DBLOAD Fishing.db
#DBFIRST
#Echo I was given %1
#LOOPVIEW {#IF ("%1" =~ "%rec.Name") {put &Keyword @fishingcontainer\#DBNEXT} {#DBNEXT}}
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