 |
Lasivian Wanderer
Joined: 25 Jan 2002 Posts: 76 Location: USA
|
Posted: 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 |
|
|
 |
Tech GURU

Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Mon Sep 21, 2009 5:58 pm |
Try quoting the if statement like so.
| Code: |
| #IF ("%1" = "&name") |
|
|
_________________ Asati di tempari! |
|
|
 |
Lasivian Wanderer
Joined: 25 Jan 2002 Posts: 76 Location: USA
|
Posted: 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 :) |
|
|
|
 |
Tech GURU

Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: 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! |
|
|
 |
Lasivian Wanderer
Joined: 25 Jan 2002 Posts: 76 Location: USA
|
Posted: 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}} |
|
|
|
|
 |
|
|
|