Display entire line in another field
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Display entire line in another field
Hi,
I have a field with about 40 lines in it. Each line begins with a date and is followed by some text, eg. "jan 15 george's birthday". I am using the Find command to find a particular date, which works great. However, I would like to then display the found LINE in another field. So, when I find a particular date, I would like the program to automatically "grab" the entire line and display it in another field. Can anyone help me in understanding how to do this? Thanks.
I have a field with about 40 lines in it. Each line begins with a date and is followed by some text, eg. "jan 15 george's birthday". I am using the Find command to find a particular date, which works great. However, I would like to then display the found LINE in another field. So, when I find a particular date, I would like the program to automatically "grab" the entire line and display it in another field. Can anyone help me in understanding how to do this? Thanks.
urbaud
Re: Display entire line in another field
urbaud...
That should help you... see the 'foundLine', the 'clickLine' in the dictionary.
take care
Dixie
Code: Select all
on mouseUp
put "Jan 1" into theDateToFind
find whole theDateToFind in fld 1
put line (word 2 of the foundLine) of fld 1 into fld 2
end mouseUp
take care
Dixie
Re: Display entire line in another field
Hi Dixie,
Thank you so much for the help. It works like a charm and it's exactly what I wanted. I added the 'Ask' command so I can search for any one of the 40 or so lines. I knew the code would be rather short, but I just didn't have a clue about how to tackle the issue. So, again, thanks for the help.
Dan
Thank you so much for the help. It works like a charm and it's exactly what I wanted. I added the 'Ask' command so I can search for any one of the 40 or so lines. I knew the code would be rather short, but I just didn't have a clue about how to tackle the issue. So, again, thanks for the help.
Dan
urbaud
Re: Display entire line in another field
I had a similar problem and this solution worked for me as well, but I wonder why. What does adding the code (word 2 of the foundLine) do, and why does this return the whole line of text and not just the second word? Sorry for the stupid questions, but this is all new to me.put line (word 2 of the foundLine) of fld 1 into fld 2
Thanks for help
m.
Re: Display entire line in another field
Hi.
Read the code again. It states: "line (word 2 of the foundline) of fld 1.
Break this down and you can see it says: "line (2) of fld 1 -- the "foundline" returns "line x of field y" --the "2" is arbitrary.
Check out the dictionary.
This is one of the beautiful things about LC, that statements are resolved before they are executed. This takes just a little getting used to, but once mastered with just a bit of experimentation, becomes incredibly powerful and fun to use.
Craig Newman
Read the code again. It states: "line (word 2 of the foundline) of fld 1.
Break this down and you can see it says: "line (2) of fld 1 -- the "foundline" returns "line x of field y" --the "2" is arbitrary.
Check out the dictionary.
This is one of the beautiful things about LC, that statements are resolved before they are executed. This takes just a little getting used to, but once mastered with just a bit of experimentation, becomes incredibly powerful and fun to use.
Craig Newman
Re: Display entire line in another field
I understand that it's returning the line number of the selection. I originally used something like -- put line foundline of field x into field y. This would return not the selected text, but a reference to the line of the selected text: "line 42 of field 1". So does the use of "word 2" in the code force LiveCode to return the text rather than the reference to the text? Could I have used "word 3" or "word 5" and have it work as well? Why doesn't the use of "word 2" limit the text returned to only the second word of that line?dunbarx wrote:Read the code again. It states: "line (word 2 of the foundline) of fld 1.
Break this down and you can see it says: "line (2) of fld 1 -- the "foundline" returns "line x of field y" --the "2" is arbitrary.
Oh. I was thinking of foundLine as a variable name, not a function. So word 2 of foundLine's returned chunk is the "lineNumber", and that explains why it works.
Thanks