HTML formatting problem

Jan Schenkel janschenkel at yahoo.com
Thu Apr 17 04:17:01 EDT 2003


--- Ron <rbarber at yhb.att.ne.jp> wrote:
> 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
> 

Hi Ron,

I had no idea it had to be case sensitive ; I usually
bracket the items I want replaced in an html-template
variable so they look like [#Item1#] and it has worked
fine for over 20 lines in my stacks ; but now I see
where you're getting at.
The only thing I wouldn't do is place the font attribs
for every line ; if you set those as the default font
attributes for your text field, you only have to
change the font attribs for the chunks that are to be
hilited.
Have you traced the script with the debugger to find
out if all the text is for a fact in thetext, if the
script drops out of the repeat loop or if the
replaceText is uncooperative ?

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