On 08/08/15 23:33, Peter M. Brigham wrote:
On Aug 8, 2015, at 3:41 PM, Richmond wrote:
I seem to be going wrong:
I have a fld "WERBS" containing:
found
returned
become
and my test to be analysed in a fld "TEKST":
My Dad ate cheese.
My Mum and Dad were returned home when it
began to rain.
He had a house in Spain.
They were become hairdressers.
They were found.
finalSolution666
But this:
on mouseUp
put 1 into textLine
put fld "WERBS" into $WERBS
put fld "TEKST" into $TEKST
put 1 into cookedLine
repeat until line textLine of $TEKST contains "finalSolution666"
put 1 into verbLine
repeat until line verbLine of $WERBS is empty
put line verbLine of $WERBS into WERB
put "were" && WERB into FRAZE
if line textLine $TEKST contains FRAZE then
put line textLine $TEKST into line cookedLine of fld "COOKED"
Missing an "of" in the two lines above:
put line textLine *of* $TEKST into line cookedLine of fld "COOKED" etc
Don't know if that's the problem.
add 1 to cookedLine
end if
add 1 to verbLine
end repeat
add 1 to textLine
end repeat
end mouseUp
put only "They were found" in line 1 of fld "COOKED"
Your script logic seems unnecessarily complex. Since it looks as if only the
last occurrence is ending up in the output field, instead of using a counter to
keep track of the next line in the field, you could just
put cr & line textLine of $TEKST after fld "COOKED"
But once again, loading a line into a field repeatedly will be much slower than
putting it into a variable in the repeat loop and then putting the variable
into the field just once when the repeat is done. Getting or putting something
from or into a field is much slower than doing the same in a variable, so just
do it once.
Also, I can see no reason to be loading your data into system variables, which is what
"$WERBS" etc is defining. The only reason to put something into a variable beginning with
"$" is if you want some other system process besides LC to be able to access the data.
-- Peter
Peter M. Brigham
pmb...@gmail.com
http://home.comcast.net/~pmbrig
Um . . . "$" is a mistake brought on by a dream I had about FORTRAN last
night: in FORTRAN IV '$" was used for string variables.
Senior moment!
Richmond.
_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode