# $EPIC: indextoword.txt,v 1.3 2006/08/01 03:47:40 sthalik Exp $ ======Synopsis:====== $__indextoword__( ) ======Technical:====== * If the argument is omitted the empty string is returned. * If the argument is a negative number the empty string is returned. * If the argument is omitted the empty string is returned. * If the length of is less than the empty string is returned. * Otherwise, the return value returns a value suitable for use with the $word() function (or other word functions) representing the word that contains the th character which should be a value returned by $index() or the like. * Remember that counts from zero! * Remember that the return value counts from zero! ======Practical:====== The most obvious application of this function is to find the word on the input line underneath the cursor. $L is the contents of the input line and $curpos() tells you where the cursor is; you can then use something like this: $word($indextoword($curpos() $L) $L) to extract the word "underneath" the cursor. This is the fundamental mechanics of how tab completion scripts know what to complete. ======Returns:====== A number suitable for use with the word manipulation functions that represents the word that contains the th character in . Both and the return value count from zero. ======Examples:====== $word($indextoword($curpos() $L) $L) returns the word under the cursor @ foo = [one two. three.] $indextoword($index(. $foo) $foo) returns 1 (the . in ``two.'') $indextoword($rindex(. $foo) $foo) returns 2 (the . in ``three.'') $indextoword(100 testing) returns the empty string