Timing (was wordOffset, repeat loop, speed?
Mark Brownell
gizmotron at earthlink.net
Mon Jan 6 14:01:01 EST 2003
Hi,
Three questions below.
Code that works for me; ten-line-limit for testing at this point:
-- button #1
global gData, tStart, tElementNum
on mouseUp
put the milliseconds into tStartTime
put the text of field "impfield" into gData
put (the milliseconds - tStartTime) && " milliseconds" into field "say"
put 0 into tStart
put 1 into tElementNum
end mouseUp
-- button #2
global gWordArray, gData, tStart, tElementNum
on mouseUP
put "" into field "say"
ask "enter a word to check"
set the wholeMatches to false
put the milliseconds into tStartTime
repeat with x = 1 to 500
put wordOffset(it,gData,tStart) into tNum
put (tNum + tStart) into tStart
if tNum < 1 then exit repeat
put tStart into gWordArray[tElementNum]
add 1 to tElementNum
end repeat
put (the milliseconds - tStartTime) && it && tElementNum && tStart && cr
into field "say"
end mouseUp
-- button #3
global gWordArray
on mouseUp
put the milliseconds into tStartTime
put keys(gWordArray) into keyWordsList
put return after field "say"
repeat for each line l in keyWordsList
put l & tab & gWordArray[l] & return after displayResult
end repeat
put (the milliseconds - tStartTime) after field "say"
put displayResult after field "say"
end mouseUp
1.) This seems a little slow. It took 2.7 seconds to do (button #2) with 400
kbytes of text & 209 possible hits for a single word.
2.) I noticed that it won't work with multiple words or empty space between
characters. I would like to work with the numericle offset of characters and
place that info gathered into an array if possible.
3.) I have an off-topic question about a single user pro-license. If I get
that version does it mean that I can use it on Mac & Windows to debug on
those OS, or will I need to get a license for each OS that I wish to
develope on? The documents were not clear enough for a carpenter regarding
this. So I'm asking here.
Thanks,
Mark Brownell
Gizmotron Graphics
More information about the use-livecode
mailing list