Translate metadata to field content
J. Landman Gay
jacque at hyperactivesw.com
Fri Feb 21 13:14:48 EST 2020
Aha! Of course. I should have thought of that. Mark pointed out the same
thing. (And yes, my brief test had the metadata in the third paragraph.)
I'll try his handler when I get back to my Mac. If my guess is correct, the
search won't take any measurable time at all and the primary delay will be
loading the htmltext into a variable.
You guys are great.
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
On February 21, 2020 4:36:42 AM "Niggemann, Bernd via use-livecode"
<use-livecode at lists.runrev.com> wrote:
> Hi Jacque,
> Jacque wrote:
> > put the styledText of fld 1 into tDataA
> > put 0 into tTotalChars
> > put 0 into tStartChar
> >repeat with i = 1 to the number of elements in tDataA
> >put tDataA[i]["runs"] into tRunsA
> >repeat with j = 1 to the number of elements in tRunsA
> > put tRunsA[j] into tRunA
> >add the num of chars in tRunA["text"] to tTotalChars
> > if tRunA["metadata"] is pTag then
> >if tStartChar = 0 then
> > put tTotalChars - len(tRunA["text"]) + 3 into tStartChar
> > end if
> >else if tStartChar > 0 then
> >put tTotalChars - len(tRunA["text"]) into tEndChar
> >select char tStartChar to tEndChar of fld 1
> >select empty
> >set the backcolor of char tStartChar to tEndChar of fld 1 to "yellow"
> >return tStartChar & comma & tEndChar
> >end if
> >end repeat
> >end repeat
> the styledArray does not include the returns at the end of a line. You have
> to add them if you address chars/codeUnits of the whole text. Initializing
> tTotalChars with -1 lets you add 1 to tTotalChars in each iterations of the
> outer repeat loop. -1 because the first line is not has no preceding return.
> Also add 1 to calculate tStartChar otherwise you point to the last char of
> preceding run.
> put -1 into tTotalChars -- note -1
> put 0 into tStartChar
> repeat with i = 1 to the number of elements in tDataA
> add 1 to tTotalChars -- account for returns
> put tDataA[i]["runs"] into tRunsA
> -- note add 1
> put tTotalChars - len(tRunA["text"]) +1 into tStartChar -- mark char 1 of
> Additionally in your implementation if the target run with the metadata you
> look for is the last run of the array nothing is returned.
> Kind regards
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
More information about the use-livecode