Wildcard in aliases

I'm not sure I understand how wildcards are used in aliases.

Here's some code for example:

Code:
void test(string fam){
    if(to_familiar(fam) == $familiar[none])
        print("Unrecognized familiar: " + fam);
    else print(to_familiar(fam));
}
calling this function directly from within a script:

Code:
test("pet rock");
Retruns, as expected:

Pet Rock


A few aliases:

Code:
alias test1 => ashq import <aaaa.ash> test("pet rock");
alias test2 => ashq import <aaaa.ash> test("%%");
using test1 returns Pet Rock

using test2...
test2 pet rock returns Unrecognized familiar: pet rock

What is happening with the wildcard that prevents the to_familiar() function from converting the string properly?



Edit to add:

I assume it has something to do with the space between pet and rock. I don't know.

test2 rock returns Rock Lobster
test2 pet returns Pet Cheezling
test2 rock lobster returns Unrecognized familiar: rock lobster

Edit: It's not the space.

test2 bulky buddy returns Bulky Buddy Box
test2 box returns
Unrecognized familiar: box
ash to_familiar("box") returns Bulky Buddy Box
 
Last edited:

heeheehee

Developer
Staff member
Hmm. I've been getting the same results. However, with
Code:
alias test => ash print($string[%%].to_familiar().to_string());
it works just fine. (Highly condensed version of the alias. Yay.)

Not entirely sure why the datatype constant using $string[] works, while using quotes doesn't.
 

jasonharper

Developer
For some reason, %% in an alias gets an extra space substituted at the end, and in a double-quoted string that space is significant - you're trying to find a familiar called "pet_rock_" (spaces turned into underscores for visibility), not "pet_rock". $string[%%] works because it trims leading and trailing whitespace. $familiar[%%] would also work here.
 
Top