Your IP : 216.73.216.48


Current Path : /usr/X11R6/share/epic5/help/6_Functions/
Upload File :
Current File : //usr/X11R6/share/epic5/help/6_Functions/wordtoindex

# $EPIC: wordtoindex,v 1.4 2002/01/13 00:27:11 anders Exp $
Synopsis:
   $wordtoindex(<number> <list>)

Technical:
   * If the <number> argument is omitted, the empty string is returned.
   * If <number> is negative, then the value 0 is returned.
   * If <number> is greater than the actual number of words in <list>, 
     then the return value of this function is the same as would be 
     returned by $strlen(<list>).
   * There is only one space that separates <number> from <list>.  Any further
     spaces between <number> and <list> are part of <list> for the purpose of
     counting.
   * The return value is the character position (as would be returned by 
     $index() and could be used by $right() et al) of the first character
     in the <number>th word in <list>.
   * <number> counts from zero!

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

See Also:
   indextoword(6); index(6); right(6); curpos(6)