HTML formatting problem

Jan Schenkel janschenkel at yahoo.com
Thu Apr 17 01:57:01 CDT 2003


--- Ron <rbarber at yhb.att.ne.jp> wrote:
> Greetings
> 
> 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.
> 
> Here's the code (watch for wrapped line):
> 
>   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
> 
>  repeat for each line l in thetext
> 
>     put replacetext(l,keyword,htext) into l
> 
>     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
>  
> 
> Does anyone else have this problem? or a solution?
> Thanks
> Ron
> 

Hi Ron,

Wouldn't it be more efficient to have them all
replaced at once ? Your script would then become :

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

Hope this helped,

Jan Schenkel.

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)

__________________________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo
http://search.yahoo.com



More information about the use-livecode mailing list