Get chars after a find command..

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Fasasoftware
Posts: 203
Joined: Mon Oct 31, 2011 9:36 pm
Contact:

Get chars after a find command..

Post by Fasasoftware » Thu Apr 25, 2013 10:45 pm

Dear friend,

I need help please...

i need a little script that find a string and then after take some chars on the right of this string...until encounter another string for example "pippo"...

I treyed this script but not work...

Code: Select all

find "minutes" in field"search"
if the foundtext is "minutes" then
put the char 1 to string"pippo" after the foundtext into field"test"
end if
In other words i need to get the chars on the right of a find command until i encounter a string that i want...in this case pippo....(it's an example)...

Thanks a lot in advance

Lestroso :oops:

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Get chars after a find command..

Post by Simon » Thu Apr 25, 2013 11:39 pm

Here you go Lestroso,

Code: Select all

on mouseUp
   put wordOffset("minutes", fld 1) into tStart
   put wordOffset("pippo", fld 1) into tEnd
   answer word tStart to tEnd of fld 1
end mouseUp
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Get chars after a find command..

Post by dunbarx » Fri Apr 26, 2013 4:00 am

Lestroso.

You see how compact and robust Simon's script is. You do not need to find anything.

But he wrote in a way that will work with words, not strings. This may be what you intended, given your example, even though you used "string" and "chars" instead of "word".

So if this is the case, you are done. But if not, and you really wanted strings (like "min" and "ppo"), can you make his ideas work for you?

Craig Newman

Fasasoftware
Posts: 203
Joined: Mon Oct 31, 2011 9:36 pm
Contact:

Re: Get chars after a find command..

Post by Fasasoftware » Fri Apr 26, 2013 3:04 pm

thank you Simon thery much!!! you helped me really.....so much!!!


Thanks a lot again.... :D :D :D

Lestroso

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Get chars after a find command..

Post by Simon » Sat Apr 27, 2013 1:41 am

Glad it worked for you!
You should check out wordOffset in the dictionary and figure out the "words to skip". That way if your search terms come up multiple times in a document you can keep track of where you were and then just skip your first find when used in a loop.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: Get chars after a find command..

Post by atout66 » Fri Mar 14, 2014 2:54 pm

As said Craig Newman, what if you search for a string ?
But if not, and you really wanted strings (like "min" and "ppo"), can you make his ideas work for you?
If I search a string like "<span class="mw-editsection">" the wordOffset() doesn't help.
Even if I write

Code: Select all

"<span class='mw-editsection'>"
I also tried with matchChunck() without success...
Discovering LiveCode Community 6.5.2.

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

Re: Get chars after a find command..

Post by Thierry » Fri Mar 14, 2014 3:10 pm

atout66 wrote: If I search a string like "<span class="mw-editsection">" the wordOffset() doesn't help.
Even if I write

Code: Select all

"<span class='mw-editsection'>"
I also tried with matchChunck() without success...
Use the quote word to replace the " inside your string.

For matchChunk, put your regex in a custom property or a field
and escape your quotes, like: \"

HTH,

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

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: Get chars after a find command..

Post by atout66 » Fri Mar 14, 2014 4:35 pm

I've got it with offset()

Code: Select all

put "API"&quote&">/" into laChaine
   get offset(laChaine,Tsource)
   put IT
Thanks :wink:
Discovering LiveCode Community 6.5.2.

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

Re: Get chars after a find command..

Post by Thierry » Fri Mar 14, 2014 4:53 pm

atout66 wrote:I've got it with offset()

Code: Select all

put "API"&quote&">/" into laChaine
   get offset(laChaine,Tsource)
   put IT
Thanks :wink:
Elle n'est pas belle, la vie ? :)

Regards,

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

Post Reply