Text selection code

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
Whytey
Posts: 31
Joined: Fri Jan 10, 2014 6:40 pm

Text selection code

Post by Whytey » Sun Jan 12, 2014 2:39 pm

What is the code to select a region of text from one point to a specific word?

Thanks!

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Text selection code

Post by Klaus » Sun Jan 12, 2014 2:44 pm

Hi,

open the dictionary -> Livecode: Menu: Help: Dictionary (API) and lookup "select". 8)

And taking a look at these stack won't hurt either:
http://www.hyperactivesw.com/revscriptc ... ences.html


Best

Klaus

Whytey
Posts: 31
Joined: Fri Jan 10, 2014 6:40 pm

Re: Text selection code

Post by Whytey » Sun Jan 12, 2014 3:52 pm

Hi Klaus, thanks for your post I'm still struggling I have this huge stream of data and this thread I am interested in in the middle of it.

'Select item 244094102.
Nucleostemin depletion induces post-g1 arrest apoptosis in chronic myelogenous leukemia k562 cells.
Seyed-Gogani N, Rahmati M, Zarghami N, Asvadi-Kermani I, Hoseinpour-Feyzi MA, Moosavi MA.
Adv Pharm Bull. 2014;4(1):55-60. doi: 10.5681/apb.2014.009. Epub 2013 Dec 23.
PMID'

By using the code
on mouseUp
find "244" in field "Results2"

I can get to this thread but I am not sure how to select from this point up to the PMID at the end and copy and paste the selection into a box called "Box1"

I hope you can help! Thanks!

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Text selection code

Post by Klaus » Sun Jan 12, 2014 4:39 pm

Hi Whytey,

OK, I see that you
1. did not really mean "select"
2. did not mean "sort" for this in another thread
3. found a way to ask this question a third time today (Hint, hint!) 8)

"find" is not the best way for your purpose, I would use "lineoffset" or
just "offset" or a combination of both here.


Best

Klaus

Whytey
Posts: 31
Joined: Fri Jan 10, 2014 6:40 pm

Re: Text selection code

Post by Whytey » Sun Jan 12, 2014 4:44 pm

LOL in my head I knew what I wanted to do!! Thanks I'll give that a go!

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 875
Joined: Wed Nov 22, 2006 3:42 pm

Re: Text selection code

Post by Thierry » Sun Jan 12, 2014 4:56 pm

Whytey wrote:I have this huge stream of data and this thread I am interested in in the middle of it.

'Select item 244094102.
Nucleostemin depletion induces post-g1 arrest apoptosis in chronic myelogenous leukemia k562 cells.
Seyed-Gogani N, Rahmati M, Zarghami N, Asvadi-Kermani I, Hoseinpour-Feyzi MA, Moosavi MA.
Adv Pharm Bull. 2014;4(1):55-60. doi: 10.5681/apb.2014.009. Epub 2013 Dec 23.
PMID'
Hi Whytey,

Regular expressions are also a nice and powerful way to go for this kind of problem,
except if you have some regex-asthma so better stick with lineoffset and co :)

Here is some code:

Code: Select all

  if matchText( yourText, "(?ms)'Select item 244094102.\n(.*?)\nPMID'", gotit) then
      put gotit
   else
      put "Not found!"
   end if
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!

Whytey
Posts: 31
Joined: Fri Jan 10, 2014 6:40 pm

Re: Text selection code

Post by Whytey » Sun Jan 12, 2014 5:09 pm

Hi Thierry, brilliant thank you. Where shall I put this code, do I need to make a button that links to where the text is (In a box called "Results2")?

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 875
Joined: Wed Nov 22, 2006 3:42 pm

Re: Text selection code

Post by Thierry » Sun Jan 12, 2014 5:36 pm

Whytey wrote:Hi Thierry, brilliant thank you. Where shall I put this code, do I need to make a button that links to where the text is (In a box called "Results2")?
Umm, really it's up to you and the way you organize your stack.
so many ways to do that.. :roll:

Happy coding :)

Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Text selection code

Post by Klaus » Sun Jan 12, 2014 5:57 pm

Bonsoir Thierry,
Thierry wrote:if you have some regex-asthma so better stick with lineoffset and co :)
I confess that I suffer heavily from that! :D
Hand me the offset-inhalator quickly 8)


Best

Klaus

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 875
Joined: Wed Nov 22, 2006 3:42 pm

Re: Text selection code

Post by Thierry » Sun Jan 12, 2014 6:25 pm

Klaus wrote:
Thierry wrote:if you have some regex-asthma so better stick with lineoffset and co :)
I confess that I suffer heavily from that! :D
Hand me the offset-inhalator quickly 8)
Hallo Klaus,
....
Be happy :)

Thierry
Last edited by Thierry on Thu Nov 17, 2022 12:37 pm, edited 1 time in total.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Text selection code

Post by Klaus » Sun Jan 12, 2014 6:31 pm

:D :D :D

In fact I really suffer from a light form of asthma and the device i use for inhaling looks a bit like yours minus the LC regex-disk:
Image

At least it is ROUND :D

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 875
Joined: Wed Nov 22, 2006 3:42 pm

Re: Text selection code

Post by Thierry » Sun Jan 12, 2014 6:42 pm

Klaus wrote: :D :D :D
In fact I really suffer from a light form of asthma and the device i use for inhaling looks a bit like yours minus the LC regex-disk:
At least it is ROUND :D
Yep but mine contains a Rasperry board with LC already in.. :roll:

and really sorry about your asthma; not really nice :(

Regards,
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Text selection code

Post by Klaus » Sun Jan 12, 2014 7:21 pm

Thierry wrote:Yep but mine contains a Rasperry board with LC already in.. :roll:
:D :D :D

Post Reply