This routine performs the sort of function usually done with grep or awk. It searches
the text text for a string search_string and then returns some or all of the current or
some following line. If lineinc is 0 then some or all of the current line is returned. If
lineinc is greater than 0 then the lineinc'th following line is returned. If word_index
is 'all' then the entire line is returned, if word_index is 'last' then the last word of the line
is returned. Otherwise word_index should be a list of one or more integers, n1,n2,..etc and the
n1th, n2th etc. words on the line will be returned in the form of a Tcl list. Note that the
numbering of the words on the line starts at 0. The format of word_index must be a Tcl list;
an example of extracting the 2nd and 4th word from a line containing the word 'Input' is shown below.
set text \
"This is a title
Input 21 25 28
result 3.5 4.2 6.1"
set input [ExtractFromText $text "Input" 0 [list 1 3]
set output [ExtractFromText - "result" 0 [list 1 3]
The first call to ExtractFromText will return a value of {21 28}, the second call will return {3.5 6.1}.
When searching for more than one line in the same text, the second call to the ExtractFromText can have
a dash character for the first argument, rather than the full search text, and then the procedure will
continue searching the previously entered text from the line it returned at the last call. Note that it is
not sensible to use this mechanism if you are not sure of the order of the search strings in the text or if
one search string may be absent from the text.