[Turn off line numbering]1: arg objs, str; 2: var obj, found, l, f; 3: 4: found = []; 5: for obj in (objs) { 6: if (type(obj) == 'frob && !valid(frob_class(obj))) 7: throw(~badfrob, "Bad Thing Frob", obj); 8: else if (obj.match_name(str)) 9: found += [obj]; 10: } 11: if (listlen(found) == 1) 12: return found[1]; 13: if (listlen(found) > 1) { 14: if ((f = filter f in (found) where (f.name() == str))) { 15: if (listlen(f) == 1) 16: return f[1]; 17: found = f; 18: } 19: throw(~ambig, "ambiguous match", found); 20: } 21: throw(~objnf, "Object not found.");
// Created 27-Mar-1995 as a part of ColdCore, see: @help Credit