HTML formatting problem
Ron
rbarber at yhb.att.ne.jp
Thu Apr 17 02:53:01 EDT 2003
Hi Jan
Thanks for replying.
>> I've been trying to use html to format some plain
>> text, specifically,
>> hiliting a keyword within sentences. The text is
>> read into a variable and
>> then html formating code is added using repeat loops
>> and then put into a
>> fld.
>>
>> The problem is that only the first 9 lines are
>> formated. The codes are
>> actually present in the variable before setting the
>> htmltext of the fld but
>> don't affect any lines after line 9. This is with
>> 2.0 beta 2 as well as
>> 1.1.1 both on OS 9.
> Wouldn't it be more efficient to have them all
> replaced at once ? Your script would then become :
Yes, and no. This has to do with the fact that I need replacetext to be case
sensitive (I didn't include that line of the script) so I can't use replace.
You could say that I could do this with replacetext instead of replace in
your script, but as a discussion recently about replace, offset, matchtext
etc. pointed out, I found that for large blocks of text, doing replacetext
every line was faster than one call for all the textblock.
>
> put "<font size=" & tsize & "color=" & tcolor & \
> "><" & tstyle & ">" & keyword & "</" & tstyle & \
> "></font><font face=" & item 2 of fontprefs && \
> "size=" & item 3 of fontprefs && "color=" & \
> item 5 of fontprefs & "><" & item 4 of \
> fontprefs & ">" into htext
>
> -- instead of line per line
> replace keyword with htext in thetext
>
> -- now process the rest of the lines
> repeat for each line l in thetext
> put "<p><font face=" & fname & " size=" & fsize & \
> "color=" & fcolor & "><" & fstyle & ">" & l & \
> "</" & fstyle & "></font></p>" & return after \
> htmltexts
> end repeat
>
> set the htmltext of fld "num1" of stack thename \
> to conctext
>
Using your script or mine, do you see the same problem as I am seeing with
only 9 lines actually showing up formatted? You can substitute any values
for the font, styles etc and just make sure to have more than 10 lines in
your input text.
Thanks
Ron
More information about the use-livecode
mailing list