alphabetical order: highlight first row
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
alphabetical order: highlight first row
Hi all,
let me explain: into a list field, I have about 200 lines containing names in alphabetical order and a group of buttons: one for each letter.
simply I want, clicking one of them, highlight the first row, and position myself, the contents of which starts with the letter corresponding to the pressed button.
be clear, I don't want to filter and to extract the rows corresponding to a certain letter, but only place the list in that point, to be visible the corresponding names.
thanks for help
franco
let me explain: into a list field, I have about 200 lines containing names in alphabetical order and a group of buttons: one for each letter.
simply I want, clicking one of them, highlight the first row, and position myself, the contents of which starts with the letter corresponding to the pressed button.
be clear, I don't want to filter and to extract the rows corresponding to a certain letter, but only place the list in that point, to be visible the corresponding names.
thanks for help
franco
Re: alphabetical order: highlight first row
Hi Franco,
You can do that using a item's list of first letter of each line like this
"a,a,b,b,b,b,e,e,e,e"
And you have just to get the itemoffset(myletter).
You have now the num of the found line and you may play with "effective textHeight" and the vScroll of your group or list fld
Best regards
Jean-Marc
You can do that using a item's list of first letter of each line like this
"a,a,b,b,b,b,e,e,e,e"
And you have just to get the itemoffset(myletter).
You have now the num of the found line and you may play with "effective textHeight" and the vScroll of your group or list fld

Best regards
Jean-Marc
https://alternatic.ch
Re: alphabetical order: highlight first row
Hi Jean-Marc,
I understand the concept, and now I will try to do.... not sure of success, in case of need I will be back here.
best regards
franco
I understand the concept, and now I will try to do.... not sure of success, in case of need I will be back here.
best regards
franco
Re: alphabetical order: highlight first row
ok, I've done this for now :
fldOrdineAlfabetico contains all the first letters, comma separated, of lines names.
I put the buttons of the letters into a group, and used their label like itemToFind.
now I must use it
edit: just
ciao
franco
Code: Select all
on mouseUp
put fld "fldOrdineAlfabetico" into tAlfabeto
put itemOffset(the label of the target, tAlfabeto) into tNumRiga
end mouseUp
I put the buttons of the letters into a group, and used their label like itemToFind.
now I must use it

edit: just
Code: Select all
set the hilitedLine of fld "fldVitigni" to tNumRiga
franco
Last edited by francof on Tue Oct 21, 2014 5:44 pm, edited 1 time in total.
Re: alphabetical order: highlight first row
Franco,

then of course you need to use LINEOFFSET!... I have about 200 lines...

Re: alphabetical order: highlight first row
Klaus,
The itemoffset return the num of the first line begining with a choose letter (the label of a btn)
Getting the vScroll of the field according the num of the found line is the next step and yes
we need lineoffset to do it
Best
Jean-Marc
No for this part, fld "fldOrdineAlfabetico" contains a list of items. A kind of index of the target list fldthen of course you need to use LINEOFFSET!
The itemoffset return the num of the first line begining with a choose letter (the label of a btn)
Getting the vScroll of the field according the num of the found line is the next step and yes
we need lineoffset to do it
Best
Jean-Marc
https://alternatic.ch
Re: alphabetical order: highlight first row
ehm... this code:jmburnod wrote: ....
Getting the vScroll of the field according the num of the found line is the next step and yes
we need lineoffset to do it
Best
Jean-Marc
Code: Select all
set the hilitedLine of fld "fldVitigni" to tNumRiga
best
franco
Re: alphabetical order: highlight first row
Ah, sorry, I see, but using another itemlist seems a bit cumbersome to me
Here a script that does what I think Franco needs.
Some hints:
1. "fld 1" is the field with your 200 lines
2. The field needs to be a LIST field
3. The script iis for your buttons and presumes that the buttons have the LABEL with the character you want to scroll to
Button name: whatever
Button label: A or B or C etc...
Tested and works
Best
Klaus

Here a script that does what I think Franco needs.
Some hints:
1. "fld 1" is the field with your 200 lines
2. The field needs to be a LIST field
3. The script iis for your buttons and presumes that the buttons have the LABEL with the character you want to scroll to
Button name: whatever

Button label: A or B or C etc...
Code: Select all
on mouseUp
put the label of me into tSearchstring
put lineOffset(return & tSearchstring, field 1) into tLine
## Character not in field, then exit handler!
if tLine > 0 then
exit mouseup
end if
## Scroll to the founmd line
set the scroll of field 1 to tLine * the effective textHeight of field 1
## Hilite that line_
set the hilitedlines of fld 1 to tLine + 1
end mouseUp

Best
Klaus
Re: alphabetical order: highlight first row
I confirm.Klaus wrote: ...
Tested and works![]()
Best
Klaus
What can I say, the Jean-Marc's solution made me work and this was a training for me. thanks to both
Klaus, just a little misprint in your script: I think you meant:
Code: Select all
if tLine = 0 then
exit mouseup
end if
A little problem with the first line (generally the "A" letter):
in my case, if the letter is "A" tLine contains 1 and when is added 1 to it the code shows me lines starting from the second line of the list.
so I've modified this:
Code: Select all
## Hilite that line_
if tLine = 1 then put 0 into tLine
set the hilitedlines of fld "fldVitigni" to tLine + 1
Code: Select all
put lineOffset(return & tSearchstring, fld "fldVitigni") into tLine
and, "effective textHeight" I did not understand what is it.
I've read on the dictionary something about the "...change the appearance of text in a field." and "Specifies the amount of space between lines of text in a field."
best
franco
Re: alphabetical order: highlight first row
Hi Franxo,
ha, you caught me! I just copied an old script of mine without thinking.
1. Yes, of coures it should read: if tLine = 0
2.
which we need to take into account later!
Actually the extre return is an an old trick, but unfortunately I have forgotten what is is good for!
3.
If you do not set a property for an object (like a textfont for fields) this object will inherit this property
from the next object in the object hierarchy.
Example:
Textfont of stack set to 12
You just create a new field aqnd do not set its textfont.
Now when you do: answer the textfon of fld 1
You will get empty, because the field does not have an explicit textfont.
But if you do: answer the EFECTIVE textfon of fld 1
You will get 12, because the addition of EFFECTIVE will also report the INHERITED property
and this is what we need here, just in case we did NOT set the textheight explicitely!
Get the picture?
Best
Klaus
ha, you caught me! I just copied an old script of mine without thinking.

1. Yes, of coures it should read: if tLine = 0
2.
As you can see I added an EXTRA RETURN before the actuak text, so we have of course one line more in the resultbut why
CODE: SELECT ALL
put lineOffset(return & tSearchstring, fld "fldVitigni") into tLine
returns a number one less than the right one?
which we need to take into account later!
Actually the extre return is an an old trick, but unfortunately I have forgotten what is is good for!

3.
Check EFFECTIVE in the dictionary!"effective textHeight"
If you do not set a property for an object (like a textfont for fields) this object will inherit this property
from the next object in the object hierarchy.
Example:
Textfont of stack set to 12
You just create a new field aqnd do not set its textfont.
Now when you do: answer the textfon of fld 1
You will get empty, because the field does not have an explicit textfont.
But if you do: answer the EFECTIVE textfon of fld 1
You will get 12, because the addition of EFFECTIVE will also report the INHERITED property
and this is what we need here, just in case we did NOT set the textheight explicitely!
Get the picture?
Best
Klaus
Re: alphabetical order: highlight first row
The extra return ensures that the match gets the letter at the start of the line and doesn't just match a letter in the middle of the first line it finds that contains it.
The script can be fixed like this:
Adding a return before the list content allows the first line to match.
The script can be fixed like this:
Code: Select all
put lineOffset(return & tSearchstring, return & field 1) into tLine
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: alphabetical order: highlight first row
Hi jacque,
thanks for the specification.
refresh your memory
and thanks for your explanations.
ciao
franco
thanks for the specification.
Klaus, do you understand?jacque wrote:The extra return ensures that the match gets the letter at the start of the line and doesn't just match a letter in the middle of the first line it finds that contains it.
The script can be fixed like this:
Adding a return before the list content allows the first line to match.Code: Select all
put lineOffset(return & tSearchstring, return & field 1) into tLine


ciao
franco
Re: alphabetical order: highlight first row
Ah, well, now, yes!
Merci Jaqueline!

Merci Jaqueline!