Page 1 of 1

Highlighting some word after retreiving a description ?

Posted: Sat May 01, 2021 6:55 am
by liveme
HI PPL,

Got a DB query returning all lines from a column related to a crfiteria.

Code: Select all

 put "SELECT * FROM itemtable WHERE itemname LIKE "& tcriteria &";" into tSQL
Next, how could one place a highlight yellow marking in the result field :
- on the full line including that expression
or ... on the words before/after the searched word ?

Would that requires counting all charaters up to the expression and then applying some color from character number "X"?
:roll:
Thanks for any help in that

PS: result fld can be a regular text fld or a Datagrid type if that makes any dif..

Re: Highlighting some word after retreiving a description ?

Posted: Sat May 01, 2021 2:41 pm
by dunbarx
Not sure what the DB stuff has to do with this, but you can always:

Code: Select all

 set the foreColor of char 28 of fld "yourField" to "yellow"
or even

Code: Select all

 set the textStyle of char 28 of fld "yourField" to "box"
How you find that char is up to you.

Craig

Re: Highlighting some word after retreiving a description ?

Posted: Sat May 01, 2021 4:44 pm
by jacque
Offset or wordOffset can find all the instances of the expression in the field if you use the third "skip" parameter and a repeat loop. Then you can repeat through the list of found chunks and set the backcolor of each chunk to yellow. I think backcolor looks more like hiliting but forecolor would work too depending on the effect you want.

Re: Highlighting some word after retreiving a description ?

Posted: Sat May 01, 2021 7:04 pm
by liveme
Thanks Jacque, yes, I think that's what I needed : wordOffset will give it a try, thanks a lot !

...As for DB, well I was thinking, maybe while the search runs it could store each "expression" locations in a table which then could be used to apply the backcolor right after...( avoiding a second lookup...) :roll: no big deal !

Tks

Re: Highlighting some word after retreiving a description ?

Posted: Sat May 01, 2021 10:33 pm
by dunbarx
, maybe while the search runs it could store each "expression" locations in a table which then could be used to apply the backcolor right after...( avoiding a second lookup...)
The search will be very fast, however you script it. Jacques suggestion of one or other of the "offset" variants, any of which are the standard way of doing such things, are virtually instantaneous.

Also, might not the raw data change from downLoad to downLoad? That would likely break any stored lookUp parameters you try to reuse. So unless you might need to extract historical search data on its own merits, why do you need to store it? In other words, what is meant by a "second lookup"?

Craig