|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Mon Mar 22, 2010 8:28 pm
%match question |
It says here that if no match is found, it returns 0. However, if it does find a match, the variables that go in the latter parts of the parameters gain values, but what does the function return? I'm hoping it returns true for an #IF statement. However, if it doesn't, would #IF (!%match(blah)) work just as well?
|
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Mon Mar 22, 2010 8:48 pm |
That help page says:
Quote: |
If it matches, the position of the match in the string is returned (starting with 1). |
Thus, it returns a positive integer if it matches, and an #if will count that as TRUE. |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Mon Mar 22, 2010 8:53 pm |
Yes, I noticed that. I'm an idiot. I came here to post, but you're very quick and efficient. Thank you.
Edit: Sadly, I'm having other errors with it. *sighs* |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Mon Mar 22, 2010 8:59 pm |
Code: |
#switch (%params)
(%ismember(%params, @c_name)) {
$_mem_num = %ismember(%params, @c_name)
$_lvl = %item(@c_lvl, $_mem_num)
$_class = %item(@c_class, $_mem_num)
$_rank = %item(@c_rank, $_mem_num)
$_clan = %item(@c_clan, $_mem_num)
$_clan_color = @clancolor(@c_clan, $_mem_num)
$_is_brackets = @isbrackets(@c_clan, $_mem_num)
#show %if($_is_brackets, "[ ", "( ")%ansi($_clan_color)$_clan%if($_is_brackets, " )", " ]")" ["$_lvl" "$_class"] "%params" ("$_rank")"
}
("all") {
$_num_items = %numitems(@c_name)
#say "Listing off all current names, this will be spammy..."
#say $_num_items " entries."
#wait 500
$_curr_item = 1
#loop $_curr_item,$_num_items {
#say $_curr_item". "%item(@c_name, $_curr_item)
$_curr_item = $_curr_item + 1
#wait 200
}
}
{
$_max_iter = %numitems(@c_name)
$_is_match = 0
$_iteration = 1
#LOOP $_iteration, $_max_iter {
$_curr_char = %item(@c_name, $_curr_iter)
#IF (%match($_curr_char, %params))
{
#show "Partial match found for "%params
$_is_match = 1
$_curr_iter = $_max_iter
}
{
$_curr_iter = $_curr_iter + 1
}
}
#IF ($_is_match)
{
#exec {find $_curr_char}
}
{
#say "Could not find "%params
#say "Make sure the name is spelled correctly, or try 'find all' to get a listing of the names."
}
}
|
All I get is: Illegal Character in Expression
I tried adjusting the #IFs and the #LOOP to no avail. I found if I delete this entire section:
Code: |
#LOOP $_iteration, $_max_iter {
$_curr_char = %item(@c_name, $_curr_iter)
#IF (%match($_curr_char, %params))
{
#show "Partial match found for "%params
$_is_match = 1
$_curr_iter = $_max_iter
}
{
$_curr_iter = $_curr_iter + 1
}
}
#IF ($_is_match)
{
#exec {find $_curr_char}
}
{
#say "Could not find "%params
#say "Make sure the name is spelled correctly, or try 'find all' to get a listing of the names."
}
|
It compiles fine, so it must be in here. Removing any or both of the #IF statements does nothing. Nor does changing the #LOOP to static numbers. Nor does any of the syntax formatting that I tried. |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Mon Mar 22, 2010 9:45 pm |
Apparently I cant put a space between the comma and the next variable in a loop..
|
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Tue Mar 23, 2010 6:18 am |
Nope, you can't. Always remember that CMUD uses Spaces as delimiters between arguments when using any #command.
|
|
|
|
|
|
|
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
|
|