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
Iceclaw
Apprentice


Joined: 11 Sep 2005
Posts: 124

PostPosted: Thu Jan 05, 2006 4:02 pm   

%contains()
 
I need a method to determine if a 'substring' is part of a string, to be executed on a database or variable.

basically
How Would I write a query that returns all record numbers that match
a short desc containing, (and possibly equal to) a string?,

%query(&Short_Desc= <What Goes here?>
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Thu Jan 05, 2006 4:17 pm   
 
try %remove or perhaps %pos and %copy
_________________
Taz :)
Reply with quote
Iceclaw
Apprentice


Joined: 11 Sep 2005
Posts: 124

PostPosted: Thu Jan 05, 2006 4:26 pm   
 
I guess I dont understand is what I use to refrence it.
%query(%pos("Test",&Short_Desc)>0)
??
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Thu Jan 05, 2006 5:25 pm   
 
#function instr {%if(%pos(%2,%1),%copy(%1,%pos(%2,%1),%len(%2)),0)}

#show @instr(albert,cheese) = 0
#show @instr(albert,ber) = ber

given this you should now be able to do the following:

%query(@instr(&Short_Desc,Test))

hope this helps
_________________
Taz :)
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5187

PostPosted: Fri Jan 06, 2006 1:45 am   
 
%query(%pos("Test",&Short_Desc)>0) or %query(%pos("Test",&Short_Desc)) should work fine.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Fri Jan 06, 2006 2:03 pm   
 
%pos returns a number doesn't it? Is a number useful for %query doesn't it need to be passed a string? Confused now Crying or Very sad
_________________
Taz :)
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5187

PostPosted: Fri Jan 06, 2006 11:47 pm   
 
%query takes a parameter of type 'expression' so it doesn't preform expansion or evaluation immediately, instead it preforms them for each record. All those that evaluate to true are returned, so any non-zero, non-null result will count as true, adding that record to the return list.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Mon Jan 09, 2006 3:19 pm   
 
Yep looked at what you said and the help again and now I get it. Thanks Very Happy

Sorry for confusing the issue Iceclaw, though you may still find that function useful for other things.
_________________
Taz :)
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