|
ardwick Novice
Joined: 31 May 2007 Posts: 32
|
Posted: Fri Oct 31, 2008 3:34 am
(2.37) #query broken? |
This is a code snippet of the default of a #switch statement. I've debugged the code the best I could down to this point where
it just fails.
As you'll see, I have #echo statements on either side of the #if inside the #while. Neither of those echo statements are
outputted to my screen. It's as if the whole thing just fails at #while.
My other database functions that specifically search for things rather than looping through using #while seem to work.
In the first part of it, the >> #echo type is still $type << is outputted to the screen. The next #echo command AFTER the whole #while code is outputted, but nothing within.
{#DBFIRST;#echo type is still $type;#while (!%null(%rec)) {#echo here;#if (%rec.type=$type) {#additem area_names %rec.name;#additem path_num %rec.num;#DBNEXT} {#echo here;#dbnext}}}
EDIT: After some more testing. I think it may have to do with the %pick going into a local variable and being strung into the #exec command. I think the #exec {#query $string} is what is failing. It may work for one option, because that option looped through all the records in the #while statement, but again, it didn't "Find" a match even though my output shows there are matches.
Here is the full script: ( dark blue indicates a mud command, red indicates a cmud script to execute, just so you know what you're looking at)
#local $type $string $area_names $path_num
nosum
setdb path
#VIEW path {name}
$type = %pick("P:Pick a Path Type",o:1,"potions","heads","high","low","medium","middle","other","guild","ranklow","rankmid","rankhigh","zone")
$string = %concat("(&type=",$type,") path 1")
#exec {#query $string}
#switch ($type=zone) {#DBFIRST;#WHILE (!%null(%rec)) {#if (%rec.type=$type && %rec.start=@current_start) {#additem $area_names %rec.name;#additem $path_num %rec.num;#DBNEXT} {#dbnext}}}
{#DBFIRST;#echo type is still $type;#while (!%null(%rec)) {#echo here 1;#echo %rec.type "AND " $type;#if (%rec.type=$type) {#additem area_names %rec.name;#additem path_num %rec.num;#DBNEXT} {#echo here 2;#dbnext}}}
#t+ {Areas}
#t+ {Starting Point Triggers}
#forall %pick('p:Select and Area:',o:1,$area_names)
{
closedb path
#switch ($type=area) {}
($type=all) {}
($type=other) {}
{#variable current_area {%i}}
getkills
setdb path
$pathdb = %item($path_num,%ismember(%i,$area_names))
#dbget $pathdb
#VIEW path {name}
#show %lf
#mxp <color red>Running to %rec.name</color>
#switch (%rec.start="The Hall of Justice") {rechoj}
(%rec.start="Cromlech") {reccromlech}
(%rec.start="Ivory Gardens Resting Room") {recivory}
(%rec.start="Nilaah's Market Center") {recnilaah}
(%rec.start="The Central Spire of the Crystal Dome") {rectayric}
(%rec.start="Tesuit Dome") {rectesuit}
{}
$run = %rec.directions
#exec {%concat(".",$run)}}
closedb path
nosum |
|
Last edited by ardwick on Fri Oct 31, 2008 4:23 am; edited 1 time in total |
|
|
|
ardwick Novice
Joined: 31 May 2007 Posts: 32
|
Posted: Fri Oct 31, 2008 4:21 am |
After even more investigation, I just simply can't get a #query to work at all. Even querying the database on the command line doesn't work. #dbget works and some of my other scripts that have use %query, etc work.
However, I can't get a hit on any query I do of any of my databases. |
|
|
|
intoK Apprentice
Joined: 18 Feb 2007 Posts: 190
|
Posted: Fri Oct 31, 2008 8:42 am |
quote brackets and &
$string = %concat("~(~&type=",$type,"~) path 1")
#EXE fault, not sure why tho |
|
|
|
Seb Wizard
Joined: 14 Aug 2004 Posts: 1269
|
Posted: Fri Oct 31, 2008 4:16 pm |
Why are you using #EXEC? The version history on 2.37 says '%query now expands variables and functions in it's argument', although I don't know if this affects #QUERY too, it's worth trying without the #EXEC...
ardwick wrote: |
After even more investigation, I just simply can't get a #query to work at all. Even querying the database on the command line doesn't work. #dbget works and some of my other scripts that have use %query, etc work.
However, I can't get a hit on any query I do of any of my databases. |
Can you give more details of what the exact command you are using from the command line is? |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Fri Oct 31, 2008 4:17 pm |
You don't need #EXEC anymore with #QUERY. #QUERY now expands variables and functions in it's arguments (as mentioned in the Version History)
So just do:
#query $string
and it should work fine. For the #QUERY not working on the command line, show me some examples. You might need to enclose your query string in quotes. For example, the help file changed to show this. If you used to do something like this:
#QUERY ((&Hit>2) && (&Dam > 2)) Weapons
now you need to do this instead:
#QUERY "((&Hit>2) && (&Dam > 2))" Weapons
This potentially breaks scripts, but it allows people to better use variables and functions in their query without needing to use #EXEC, which was causing problems in the past. |
|
|
|
ardwick Novice
Joined: 31 May 2007 Posts: 32
|
Posted: Fri Oct 31, 2008 10:58 pm |
The quotations fixed the scripts. Thanks.
|
|
|
|
|
|
|
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
|
|