
CHARACTER POSITION
The return values of the Find commands would not be very useful unless you had some way of
fetching the found word back out of the Director text chunk you were searching. These
commands, in tandem with the Find commands can be used to do things like highlight the found
word in a Director field or display the found word in context with the other words on the same
line.
GetWordOfCharPosition(sourceString,characterNumber) - where sourceString is the string to
search in and characterNumber is the integer character position in the string. Returns an integer
word number in sourceString of word containing the specified character position or 0 if no word
contains the character position or if there was an error. Converts the character position returned
by one of the Finds to a word number in the text chunk.
Example:
on showWord fieldName,theWord
-- Finds a word in a field and highlights it
--
set charPos = FindNext(field fieldName,theWord)
if TC_GetLastError() = 0 then
set wordNum = GetWordOfCharPosition(field fieldName,charPos)
if wordNum > 0 then
hilite word wordNum of field fieldName
end if
end if
end
Online Help
27
Comentarios a estos manuales