Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Latino
Beginner


Joined: 16 Feb 2017
Posts: 12

PostPosted: Thu Feb 16, 2017 11:38 am   

Looking for a specific Room Name
 
I found this sweet script in the forums here, awesome!
It searches for rooms containing the name, or part of the name provided.

Can i make a version wich will match the exact room name? (using "=" instead of "LIKE")
I tried to modify it but i dont know SQ can some one help please?

here is the code:


Code:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <alias name="MapFind" copy="yes">
    <value><![CDATA[#if (%-1 != %null) {
  $room = %lower(%-1)
  $str = %concat("[Name] LIKE '%", $room, "%'")
  $locations = %mapquery($str)
  #call %roommode(1)
  #print ""
  #mxp {<color brown><hr></color>}
  $msg = "<strong><color khaki>VNum" + %repeat(" ",4) + "Destinations" + %repeat(" ",31) + "Zones</color></strong>"
  #print $msg
  #mxp {<color brown><hr></color>}
  #forall $locations {
    $roomNum = %roomnum(%i)
    $roomName = %roomname(%i)
    $roomZone = %zonename(%roomzone(%i))
    $msg = "<color white>[<color gold>" +
      %repeat(" ", 5-(%len($roomNum))) +
      $roomNum + "</color>]</color><color silver> " +
      $roomName%repeat(" ", 40-(%len($roomName))) +
      "</color><color lime>   " + $roomZone + "</color>"
    #print $msg
    }
  #mxp {<color brown><hr></color>}
  #call %roommode(0)
  } {
  #print "<color red>NO ROOM NAME PROVIDED. ENTER THE ROOM NAME OR PART OF THE NAME.</color>"
  }]]></value>
    <notes>Enter MAPFIND "room name or part of room name"</notes>
  </alias>
</cmud>
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Thu Feb 16, 2017 2:00 pm   
 
Try:
$str = %concat("[Name] = ", $room)
_________________
Discord: Shalimarwildcat
Reply with quote
Latino
Beginner


Joined: 16 Feb 2017
Posts: 12

PostPosted: Thu Feb 16, 2017 2:33 pm   
 
shalimar wrote:

Try:
$str = %concat("[Name] = ", $room)


didnt work Crying or Very sad
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Feb 16, 2017 6:31 pm   
 
SQL likes to have its quotes too.
$str = %concat("[Name] = '", %replace($room, "'", "''"), "'")
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Latino
Beginner


Joined: 16 Feb 2017
Posts: 12

PostPosted: Sat Feb 18, 2017 11:21 am   
 
Vijilante wrote:

SQL likes to have its quotes too.
$str = %concat("[Name] = '", %replace($room, "'", "''"), "'")


When i read Vijilante answered, i thought ok, its done! i know about u from forums, u r amazing!

this time didnt work tho! Crying or Very sad

it dosent store any data, i get blank "VNum, Name, ZONE" fields, i guess i need to adjust something after the FORALL

thank u tho u r always nice!


Last edited by Latino on Sat Feb 18, 2017 11:23 am; edited 1 time in total
Reply with quote
Latino
Beginner


Joined: 16 Feb 2017
Posts: 12

PostPosted: Sat Feb 18, 2017 11:22 am   
 
ERROR
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Sat Feb 18, 2017 1:08 pm   
 
Or it could be a case sensitive issue?
Try changing:

$room = %lower(%-1)
to
$room = %-1
_________________
Discord: Shalimarwildcat
Reply with quote
Latino
Beginner


Joined: 16 Feb 2017
Posts: 12

PostPosted: Sat Feb 18, 2017 2:18 pm   
 
shalimar wrote:

Or it could be a case sensitive issue?
Try changing:

$room = %lower(%-1)
to
$room = %-1


Very Happy Very Happy Very Happy

YEAH! thats it! now its perfect for what i need! thank u so much! id love to have ur knowledge Razz

Very Happy Very Happy Very Happy
Reply with quote
Latino
Beginner


Joined: 16 Feb 2017
Posts: 12

PostPosted: Sat Feb 18, 2017 2:27 pm   
 
shalimar wrote:

Or it could be a case sensitive issue?
Try changing:

$room = %lower(%-1)
to
$room = %-1


I spoke too early! xD

It worked on the first try, after that was doing again the same type of search :(
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Sun Feb 19, 2017 2:08 am   
 
Are you making sure to use the proper case for the roomname as stored in your map database when you call the alias?
_________________
Discord: Shalimarwildcat
Reply with quote
Latino
Beginner


Joined: 16 Feb 2017
Posts: 12

PostPosted: Tue Feb 21, 2017 9:56 am   
 
shalimar wrote:
Are you making sure to use the proper case for the roomname as stored in your map database when you call the alias?


200% sure!

i dont really get this, pls help!
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Thu Feb 23, 2017 1:22 pm   
 
I'm really not sure what to say...
If it worked once and then stopped, it sounds like an issue specific to you.
Did you accidently leave it open and type something in that might have broken the script?
_________________
Discord: Shalimarwildcat
Reply with quote
Latino
Beginner


Joined: 16 Feb 2017
Posts: 12

PostPosted: Fri Feb 24, 2017 11:37 am   
 
i thought about that, so i made a fresh new session and loaded the script, which worked as on my main session.

when i tried to execute it from an 3th new session applying ur suggestions, it didnt even fire "correctly" the first time, got just a blank field as on my main session
Reply with quote
chosig
Novice


Joined: 20 Apr 2008
Posts: 39
Location: Sweden

PostPosted: Fri Feb 24, 2017 3:07 pm   
 
It's a SQLITE database, if you want case insensitive searches you do something like this:

Code:
$str = %concat("[Name] LIKE '", $room, "' COLLATE NOCASE")


Oh, and also that's exact search with no wildcard in the start/end.
Reply with quote
Latino
Beginner


Joined: 16 Feb 2017
Posts: 12

PostPosted: Fri Feb 24, 2017 7:12 pm   
 
chosig wrote:
It's a SQLITE database, if you want case insensitive searches you do something like this:

Code:
$str = %concat("[Name] LIKE '", $room, "' COLLATE NOCASE")


Oh, and also that's exact search with no wildcard in the start/end.


Brilliant! 100% right! thanks god u passed by!
thank you
Reply with quote
chosig
Novice


Joined: 20 Apr 2008
Posts: 39
Location: Sweden

PostPosted: Sun Feb 26, 2017 3:57 pm   
 
Finally something I could answer, I blow at cMUD scripting, but SQL is my game... Wink
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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