Jane Austen's peculiarity
Richmond
richmondmathewson at gmail.com
Sat Aug 8 16:51:34 EDT 2015
On 08/08/15 23:33, Peter M. Brigham wrote:
<snip>
> 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.
<snip>
> 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
>
>
Well, as per your suggestion I did this:
on mouseUp
put 1 into textLine
put fld "WERBS" into WERBS
put fld "TEKST" into TEKST
repeat until line textLine of TEKST contains "finalSolution666"
put textLine into fld "KOUNT"
put 1 into verbLine
repeat until line verbLine of WERBS is empty
put line textLine of TEKST into fld "LYNE"
put line verbLine of WERBS into WERB
put "were" && WERB into FRAZE
put FRAZE into fld "FRAZE"
if line textLine of TEKST contains FRAZE then
if fld "COOKED" is empty then
put line textLine of TEKST after fld "COOKED"
-- this is here so that line 1 of fld "COOKED" does not
end up empty
else
put cr & line textLine of TEKST after fld "COOKED"
end if
end if
add 1 to verbLine
end repeat
add 1 to textLine
end repeat
end mouseUp
but still get only the last value.
Richmond.
More information about the use-livecode
mailing list