Method code for $parse_lib.object_match()

[Turn on line numbering]
arg name, @who;
var msg;

// .object_match("name"[, who])
// -> 0        name was the empty string
// -> ~objnf   nothing matched name
// -> ~ambig   more than one object matched name
// Attempt to match an object name with who.match_environment().  If one
// is found, return it.  Else, print a message and return one of the above
// false values.
// 'who' defaults to sender().
who = who ? who[1] : sender();
if (!name) {
    (| who.tell("You must give the name of something.") |);
    return 0;
}
catch ~objnf, ~ambig {
    return who.match_environment(name);
} with {
    switch (error()) {
        case ~objnf:
            msg = "I don't see any \"" + name + "\" here.";
        case ~ambig:
            msg = "I don't know which \"" + name + "\" you mean.";
    }
    (| who.tell(msg) |);
    return error();
}

// Created 27-Mar-1995 as a part of ColdCore, see: @help Credit

Tlon