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

[REBOL] Re: VID questions 2

From: brett::codeconscious::com at: 26-May-2001 21:33

Hi Robert,
> 1. How can I update the picked line of a text-list? I don't want to update
> whole list, just the picked line.
Have a play with this program. It updates the picked lines by changing the underlying string. ; ; Shows that strings of a text-list can be changed. ; Note that the strings that are changing are stored in ; the block block-of-strings. ; You can select multiple lines with the CTRL key. text-list-changer: context [ info1: tlist1: none ; Face variables block-of-strings: COPY/DEEP system/locale/months update-picked: does [ foreach string tlist1/picked [append string "*"] show tlist1 info1/text: mold block-of-strings show info1 ] lo: layout [ tlist1: text-list data block-of-strings button 150x25 "Append *" [update-picked] info1: info 600x100 ] set 'show-the-demo does [view lo] ] show-the-demo ; ; This next one demonstrates changing a line completely text-list-changer2: context [ tlist2: none ; Face variables block-of-strings: ["one" "two" "three" "four" "five"] lo: layout [ tlist2: text-list data block-of-strings button 150x25 "Change picked" [changed-picked] text "Only changes the first of a set of lines that share a string." ] changed-picked: does [ foreach string probe tlist2/picked [ change find/only tlist2/texts string mold now/time ] clear tlist2/picked ; Ensure no invalid keys are left in picked show tlist2 ] set 'show-the-demo2 does [ view lo ] ] show-the-demo2
> 2. Here is a none VID question: I have a list of objects which have
> variables. I would like to search for an object having a specific value in
> given variable. Something like: > > obj1: make object! [a: b: c: ""] > obj2: obj3: make obj1 [] > mylist: make list! [obj1 obj2 obj3] > > find mylist/obj?/a "test" > > Will return the object from the list, which has the value "test" stored in
> variable 'a > > Is there a way to do this, without writing an own iterator? Robert
I don't think so but I could be wrong. Regards, Brett.