Highlighting some word after retreiving a description ?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
liveme
Posts: 240
Joined: Thu Aug 27, 2015 5:22 pm
Location: down under

Highlighting some word after retreiving a description ?

Post by liveme » Sat May 01, 2021 6:55 am

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..

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9669
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Highlighting some word after retreiving a description ?

Post by dunbarx » Sat May 01, 2021 2:41 pm

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

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7237
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Highlighting some word after retreiving a description ?

Post by jacque » Sat May 01, 2021 4:44 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

liveme
Posts: 240
Joined: Thu Aug 27, 2015 5:22 pm
Location: down under

Re: Highlighting some word after retreiving a description ?

Post by liveme » Sat May 01, 2021 7:04 pm

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9669
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Highlighting some word after retreiving a description ?

Post by dunbarx » Sat May 01, 2021 10:33 pm

, 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

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”