|
offset and the line /word number
At 13/00 05/11/99 +0800, Arky wrote:
>
> in my work, i use "offset" function to get the char number of a special
word in a textfield, but what i want is the line number of the special
word in the textfield, can you give me some idea? thanks!
>
>
Like this:
on calcNoLines myText,charpos
halfText = chars(myText,1,charPos)
return the number of lines of halftext
end
on calcNoWords myText,charpos
halfText = chars(myText,1,charPos)
return the number of words of halftext
end
>how to count the number of characters up to and including character one
>of a given word in a textmember.
-- Welcome to Director --
dMbr = member("test")
givenWord = 7
--
put 1 + dmbr.text.word[1..givenWord].chars.count ¬
- dmbr.text.word[givenWord].chars.count
-- 36
To the latter Andy Fuchs remarked:
Bei einem Text mit 250.000 Zeichen suche ich das 1000ste Wort:
Ergebnis:
-- "5483 Zeichen/ 139 milliseconds"
Andy schreibt:
dMbr = member("test")
givenWord = 57
t = dmbr.text
put 1 + t.word[1..givenWord].chars.count ¬
- t.word[givenWord].chars.count
Ergebnis:
-- "5483 Zeichen/ 73 milliseconds"
Ergo: eine Zeile mehr, aber fast doppelt so schnell :-)
|