I want to look for a word in a tab itemdel field and if found return the line the word was found in. I am using
repeat with i = 1 to the number of lines in fld fA
set the cursor to busy
if item 1 of line i of fld fA = lookFor then
????????????????????????????????
exit repeat
end if
end repeat
Is this the best way to approach the problem?
What do I put in ???????????????????????????????? to retrieve the line in fld fA in which lookFor is item 1 ?
Also: How would I scroll fld fA to the line in which lookFor is item 1 ?
search a field
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 73
- Joined: Sat Apr 08, 2006 6:51 pm
search a field
In nova fert animus mutatas dicere formas corpora.
Re: search a field
Preston...
Not knowing exactly what you want to do but something like this might get you pointed in the right direction
or maybe this if it is item 1 of the line you are after
Make sure that there is a text size in 'text formatting' in the property inspector of the fld... else it doesn't work.
be well
Dixie
Not knowing exactly what you want to do but something like this might get you pointed in the right direction
Code: Select all
on mouseUp
put whatever into theWordToFind
put lineOffset(theWordToFind,fld 1) into theLine
set the scroll of fld 1 to (theLine * the textheight of fld 1)
end mouseUp
Code: Select all
on mouseUp
put whatever into theWordToFind
put lineOffset(theWordToFind,item 1 of fld 1) into theLine
set the scroll of fld 1 to (theLine * the textheight of fld 1)
put theLine
end mouseUp
be well
Dixie
-
- Posts: 73
- Joined: Sat Apr 08, 2006 6:51 pm
Re: search a field
Dixie,
Many, many thanks!
Preston
Many, many thanks!
Preston
In nova fert animus mutatas dicere formas corpora.
Re: search a field
Hi,
@ Dixie
here is a way to set the scrolling that I like very much for wrapped lines. For fields that have their dontWrap property set to false. The line number will not always be useful in that case. In case you don't know this I guess you might like it too.
if you want to be more precise with scrolling you could fiddle with the borderwidth and the margins but this should meet most needs of scrolling text into view.
Kind regards
Bernd
@ Dixie
here is a way to set the scrolling that I like very much for wrapped lines. For fields that have their dontWrap property set to false. The line number will not always be useful in that case. In case you don't know this I guess you might like it too.
Code: Select all
on mouseUp
put field "What" into theWordToFind
put lineOffset(theWordToFind,fld 1) into theLine -- do whatever with the line number
-- find the scroll
put offset (theWordToFind, field 1) into tChar
set the vscroll of field 1 to (the formattedHeight of char 1 to tChar of field 1) - the effective textHeight of field 1
end mouseUp
Kind regards
Bernd