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
Saros
Newbie


Joined: 19 May 2016
Posts: 9

PostPosted: Wed May 25, 2016 2:11 am   

%countlist: commas
 
Code:
#echo %COUNTLIST(test|test|test|testb|testb|test'b|test'b)

test=3|testb=2|test'b=2
Code:
#echo %COUNTLIST(test|test|test|testb|testb|test,b|test,b)

test=4|testb=2


%countlist seems to not like commas. I have tried to escape the comma, but it made no difference. Any suggestions?

EDIT: I see now, this is a known bug.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Wed May 25, 2016 4:08 pm   
 
The problem is not the commas; it is the lack of quotes.
#echo %COUNTLIST("test|test|test|testb|testb|test,b|test,b")
Also this would work.
$var="test|test|test|testb|testb|test,b|test,b"
#echo %COUNTLIST($var)
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Wed May 25, 2016 11:02 pm   
 
It's actually not a bug at all. The comma is used to separate parameters in function calls. You were passing "test|test|test|testb|testb|test" as the first parameter, "b|test" as the second parameter, and "b" as the third parameter. The countlist function only checks the first parameter, and correctly reports that test appears 4 times, and testb appears twice. This is expected behavior. Vijilante's correction is not a workaround to a bug, that's just the correct way to express a literal string. zScript does try to be forgiving whenever possible, but using quotes is the proper syntax, and will ensure that you get no unexpected results in edge cases such as this.
Reply with quote
Saros
Newbie


Joined: 19 May 2016
Posts: 9

PostPosted: Mon May 30, 2016 12:47 am   
 
Vijilante wrote:
The problem is not the commas; it is the lack of quotes.
#echo %COUNTLIST("test|test|test|testb|testb|test,b|test,b")
Also this would work.
$var="test|test|test|testb|testb|test,b|test,b"
#echo %COUNTLIST($var)


Daern wrote:
It's actually not a bug at all. The comma is used to separate parameters in function calls. You were passing "test|test|test|testb|testb|test" as the first parameter, "b|test" as the second parameter, and "b" as the third parameter. The countlist function only checks the first parameter, and correctly reports that test appears 4 times, and testb appears twice. This is expected behavior. Vijilante's correction is not a workaround to a bug, that's just the correct way to express a literal string. zScript does try to be forgiving whenever possible, but using quotes is the proper syntax, and will ensure that you get no unexpected results in edge cases such as this.


I am sorry, but, when using quotes or no quotes, a single parameter or multiple parameters the result is the same.
Any other ideas?

By the way, the documentation does not describe multiple parameters. Yes, I now understand how that works. Thank you!!!
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