Table of Contents

# $EPIC: wordtoindex.txt,v 1.2 2006/08/20 18:32:13 sthalik Exp $

Synopsis:

$wordtoindex(<number> <list>)

Technical:

Practical:

The most practical use of this function is to permit you to find the beginning position of a word in a string, especially after you have had to change the length of some of the words in the list. This technique is most obviously used by tab completion scripts which will take the input line ($L), the cursor position ($curpos()), and use the $indextoword() function to figure out where the cursor is. Then they rewrite the input line using tab completion, and use $wordtoindex() to figure out where the cursor is supposed to go after the input line has been rewritten.

Returns:

The number of characters before the beginning of the <number>th word in <list>, where <number> counts from zero.

Examples:

$wordtoindex(2 foo bar blah)           returns 8
$wordtoindex(999 foo bar blah)         returns 12
$wordtoindex(-1 foo bar blah)          returns 0