something is blocking my brain. I searched the dictionary, I googled at my best knowledge, nothing found.
Maybe some kind soul can help me with a one-liner?
Problem:
I have a locked field (MyFld), that contains multiple lines of entries.
I have an input field, and whenever something is written in, it should jump to the first line of MyFld where the line begins with what I typed.
Basically: Find the first line of fld MyFld that starts with my searchstring (= text of input field, at keydown), and return the line_number.
So I can set the selection in MyFld and scroll appropriately.
Tried:
Code: Select all
on keydown what
[!]get the lineoffset(what, fld MyFld)[/!] -- <- Problem: This returns \
the first line where what is in, not the first line starting with what ...
select line it of fld MyFld
set the vscroll of fld MyFld to 24*it
pass keydown
end keydown
It's only the first line of this script that is the problem! I know I can script it somehow, but I'm sure there's a built in function for this - am I wrong?
Else I'd write something like:
Code: Select all
repeat with i = 1 to the number of lines of MyFld
if char 1 to length(what) of line i of fld MyFld = what then
I just fear this would be slow - there must be a function to do it, and I'm just too much blocked to find it ...
Thx for any help!