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

Natural selection

 [1/3] from: patrick::philipot::laposte::net at: 13-Jul-2003 11:31


Hi list, Text-lists have build-in selection capabilities. The selected items being available in list-name/picked. Is it possible to get the selection capabilitie whith list ? This kind of list: mydata: ["Red" "Green" "blue"] view center-face layout [ mylist: list 200x100 [ text 80 ] supply [ face/text: either count > length? mydata [""][pick mydata count] ] ] Regards Patrick

 [2/3] from: philb:upnaway at: 13-Jul-2003 21:45


Hi Partrick, This is not exactly compatible .... and pretty ugly. This program stores a record number with each line (beyond the end of the list so we cant see it), and creates a picked block with the list. This picked block holds the count field rather than the picked text's. On selecting the record we check to see if it is in the picked list, if not add it, else remove it. Two changes have been made to supply 1. Store the count in the field rec-no. 2. check to see if count is in the picked list ... if so highlight the text face. ------------------------------------------------------------------------------- mydata: ["Red" "Green" "blue"] view center-face layout [ mylist: list 200x100 [ across text 200 [ either none = lv-temp: find mylist/picked to-integer rec-no/text [mylist/picked: append mylist/picked to-integer rec-no/text] [remove lv-temp] ] rec-no: text 1 ] with [picked: copy []] supply [ face/text: either count > length? mydata [""][pick mydata count] rec-no/text: count either (find mylist/picked count) <> none [face/color: brick] [face/color: none] ] ] -------------------------------------------------------------------------- As I said pretty ugly, but it works. You do have access to the indicies of the picked records, and this method doesnt suffer from the duplicate selection "feature" of text-lists. Cheers Phil === Original Message === Hi list, Text-lists have build-in selection capabilities. The selected items being available in list-name/picked. Is it possible to get the selection capabilitie whith list ? This kind of list: mydata: ["Red" "Green" "blue"] view center-face layout [ mylist: list 200x100 [ text 80 ] supply [ face/text: either count > length? mydata [""][pick mydata count] ] ] Regards Patrick

 [3/3] from: patrick:philipot:laposte at: 13-Jul-2003 17:37


Thanks Phil, I had mono-selection in mind... However based on your code, I managed to get mono-selection. It's pretty ugly too ;-)) mydata: ["Red" "Green" "blue"] view center-face layout [ mylist: list 200x100 [ across text 200 [ either mylist/picked = v-temp: to-integer rec-no/text [mylist/picked: 0] [mylist/picked: v-temp] either mylist/picked <> 0 [ face/color: brick ][ face/color: none ] show mylist ; print mold mylist/picked ] rec-no: text 1 ] with [picked: to-integer 0] supply [ face/text: either count > length? mydata [""][pick mydata count] rec-no/text: count either mylist/picked = count [ face/color: brick ][ face/color: none ] ] ] Regards Patrick ----- Original Message ----- From: <[philb--upnaway--com]> To: <[rebol-list--rebol--com]> Sent: Sunday, July 13, 2003 3:45 PM Subject: [REBOL] Natural selection
> Hi Partrick, > > This is not exactly compatible .... and pretty ugly. > > This program stores a record number with each line (beyond the end of the
list so we cant see it), and creates a picked block with the list. This picked block holds the count field rather than the picked text's.