Go to item word

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jwtea
Posts: 66
Joined: Fri Mar 23, 2018 2:01 am

Go to item word

Post by jwtea » Thu May 10, 2018 5:47 am

Hello everybody!

As i using the function "Find" as the function only circle the word.

But can i know how i can go to the location of the word?

Because i got a group with scrollbar and inside there alot of word with so anyone know what the code for me to go the location of the word.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Go to item word

Post by jmburnod » Thu May 10, 2018 11:40 am

Hi,
What is the form of your list of words in your group
One fld per word ? many words in one fld ?
This script works with a fld in a group

Code: Select all

on doFindWord pWord
   find pWord in fld 1
   put the foundchunk into tFC
   select tFC
   put the selectedLoc into tSL
   answer "foundchunk= " && tFC & cr & "selectedLoc ="  &&tSL
end doFindWord
Now you get the selectedLoc
You have to do some math to set the vScroll of your group
Good luck for next step
Jean-Marc
https://alternatic.ch

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

Re: Go to item word

Post by dunbarx » Thu May 10, 2018 2:03 pm

But can i know how i can go to the location of the word?
Jean-Marc has given a lot of help here, but is that what you meant by "location"?

Craig Newman

jwtea
Posts: 66
Joined: Fri Mar 23, 2018 2:01 am

Re: Go to item word

Post by jwtea » Fri May 11, 2018 2:03 am

Hello, as i got a alot of data inside a group call "scrolling".

Therefore when i find the word, i want to instantly go the searched word location without using the scrollbar ~ ~

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

Re: Go to item word

Post by dunbarx » Fri May 11, 2018 4:16 am

Hmmm.

When LC finds a word in a list field, say, that field automatically scrolls to the line containing that word

Is that you want "the foundLine", the actual line containing the text?

Know that the "foundLine" can be used to set the scroll of the field. You just get the effective textHight of the field and multiply that by word 2 of the foundLine. You may need a little extra adjustment when you do that, though.

But is that what you meant? Or are there several fields in your group, and you want to get more information about where the found text is located? Or is it that you want the group itself to scroll to the field that contains the found text, assuming the group is built that way? Please try to explain.

Craig

jwtea
Posts: 66
Joined: Fri Mar 23, 2018 2:01 am

Re: Go to item word

Post by jwtea » Fri May 11, 2018 4:57 am

Hello Craig, thanks for the responsive reply!
dunbarx wrote:
Fri May 11, 2018 4:16 am

Is that you want "the foundLine", the actual line containing the text?

Know that the "foundLine" can be used to set the scroll of the field. You just get the effective textHight of the field and multiply that by word 2 of the foundLine. You may need a little extra adjustment when you do that, though.

Craig
Yes this is what i mean! So you know what code i should put in button script??

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Go to item word

Post by jmburnod » Fri May 11, 2018 5:31 pm

Hi jwtea,
Yes this is what i mean! So you know what code i should put in button script??
Yes and maybe, 8)

Yes, we know how set the vScroll from a string search.
Maybe, because the best way to do that depends on context.

I repeat my questions
What is the form of your list of words in your group
One fld per word ? many words in one fld ?

With some others
Why do you need a group and not a simple field ?
Your fields are list fld or not ?
Do you may post a simple stack which should make help easier ?

If your fld is a list fld, Craig gave you what you need
Best regards
Jean-Marc
https://alternatic.ch

jwtea
Posts: 66
Joined: Fri Mar 23, 2018 2:01 am

Re: Go to item word

Post by jwtea » Mon May 14, 2018 2:33 am

Hello Jean, thanks for your time and help!
jmburnod wrote:
Fri May 11, 2018 5:31 pm

What is the form of your list of words in your group
One fld per word ? many words in one fld ?

I got around 1 group called "scrolling group" and inside the "scrolling group" i got 10 groups each of them is named "usersbox" , "usersbox 1" , "usersbox 2" and etc.... until "usersbox 9".
And each of the "usersbox" got 1 field is call "name" .
In the field is only 1 word.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Go to item word

Post by jmburnod » Mon May 14, 2018 9:46 am

Hi jwtea,
i got 10 groups each of them is named "usersbox" , "usersbox 1" , "usersbox 2" and etc.... until "usersbox 9".
userbox 1 until userbox 10 is should be better

You may use a loop to get the group containing string search inside its fld
Pseudocode:
get the name of group with search word in its fld "name" by loop
put the value of word 2 of it into tNumGroup

After this you have to do some math to get the new vSroll of your group "scrolling group".
Something like that:

Code: Select all

function fDeNumToScroll pNum,pHeight -- num of found group, height of groups 
   put (pNum-1)* pHeight into tScroll
   return tScroll
end fDeNumToScroll
This should works if your groups "userbox" have the same height
EDIT: and the height your scrolling group = the height of groups "userbox. Also depends of the height of your scrolling group

I remain curious about the necessity to use a group to do that.
https://alternatic.ch

Post Reply

Return to “Talking LiveCode”