Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

series/text-list position

 [1/3] from: mattsmac:hotma:il at: 13-Nov-2003 8:12


I have a text-list in a layout whos order corresponds to the order of a series. ie element 2 of the text-list corresponds to element 2 of the series. I want to be able to remove an element from the text-list and have the corresponding element in the series removed as well. What I can't figure out is how to find out the position of the currently selected element in the text-list. If I could find that then I could just issue something like i: text-list-position s: skip s i remove s where s is the series I am trying to alter thanks, Matt

 [2/3] from: rotenca::telvia::it at: 13-Nov-2003 17:51


Hi matt,
> I have a text-list in a layout whos order corresponds to the order of a > series. ie element 2 of the text-list corresponds to element 2 of the
<<quoted lines omitted: 3>>
> in the text-list. If I could find that then I could just issue something > like
view layout [text-list data ["a" "b" "c"] [print index? face/lines remove face/lines]] undocumented and unsecure feature, it can change in the future versions of Rebol. --- Ciao Romano

 [3/3] from: antonr:iinet:au at: 14-Nov-2003 12:27


Try this: view layout [t: text-list "hello" "there" "hello" "anton"] (Now click on the first item)
>> t/picked
== ["hello"]
>> t/data
== ["hello" "there" "hello" "anton"]
>> find t/data t/picked/1
== ["hello" "there" "hello" "anton"]
>> index? find t/data t/picked/1
== 1 One problem with text-lists is that if you have more than one item with an equal value, then when you pick one, the other ones will also be picked. So it's good/necessary to ensure you have unique values in your text-list. eg. This list is problematic: hello there hello anton If you pick the first "hello", the second one will also be shown as selected, and vice versa, if you pick the second one, the first one is also shown as selected. This means that if your values are not unique, then it is difficult to find the index in the series by using: index? find series value because you may have intended only the second value to be picked. A possible solution is to ensure your values are unique by adding an index number to the beginning of each string (or a number of invisible whitespaces at the end of secondary instances of values). Anton.

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted