58d @verb #1492:"match_choice" this none this rxdo #60 @program #1492:"match_choice" this none this "match_choice(input string)" "returns the index of the choice, or 0." "is noisy." if (this:_textp()) player:tell($string_utils:pronoun_sub("%T is looking at a text node and has no choices.")) return 0 endif input = args[1] which = $code_utils:toint(input) len = length(value = this.value) if (typeof(which) == $INT) if (which < 1 || which > len) player:tell("Sorry, ", input, " isn't a number between 1 and ", len, ".") return 0 endif return which else exact = partial = {} for choice in [1..len] valchoice = value[choice][2..index(value[choice], " ") - 1] if (input == valchoice) exact = {@exact, choice} elseif (index(valchoice, input) == 1) partial = {@partial, choice} endif endfor if (length(exact) > 1) player:tell("I'm not sure whether you meant ", $string_utils:english_list(exact, "", " or "), ".") return 0 elseif (exact) return exact[1] elseif (length(partial) > 1) player:tell("I'm not sure whether you meant ", $string_utils:english_list(partial, "", " or "), ".") return 0 elseif (partial) return partial[1] else player:tell("Sorry, there is no choice named ", toliteral(input), ".") return 0 endif endif "Last modified by Dax (#789) on Wed May 4 06:36:13 2005 MDT." . 0