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

[REBOL] Re: Just two ways to the same place?

From: tim-johnsons:web at: 29-Aug-2007 7:37

On Tuesday 28 August 2007, Kai Peters wrote:
> Hi Tim ~ > > tried to think of a situation where I'd use that and could > not come up with anything - do you have a practical example > you can share?
:-) I use many. The code below has been modified to remove any dependencies, so it may break when you test it, but any error should be obvious, and hopefully the concept is clear. Data stored in the anonymous context is presistant, I use it to create html buttons with inline javascript for rollover effects. It has two helpful characteristics: 1)"Dictionary style" argument list. 2)No need to redundantly call with a large 'args list context [ type: "button" name: "button" value: "click me" bgc: "#cccccc" color: "black" hcolor: "lightblue" fs: "12px" fw: "normal" hbgc: "black" onclick: "" ;; previous defined words kws: [type name value bgc color hbgc hcolor fs fw onclick] set 'do-button1 func[ "create a button using 'button function with keywords" [catch] args[block!] "keywords: type, name, value, bgc, color, hbgc, hcolor, fs, fw, onclick" /local use-onclick test blk][ foreach[key val] args[ if not in self key [throw make error! rejoin["Unknown key: " form key ". Use one of: [" form kws "]"]] if key = 'onclick[use-onclick: true] either word? val[ set in self key get val ][set in self key val] ] blk: copy ["<input type=^"" self/type "^" name=^"" self/name "^" value=^"" self/value "^" style=^"background-color: " self/bgc "; color: " self/color "; font-weight: " self/fw "; font-size: " self/fs ";^" onmouseout=^"this.style.backgroundColor='" self/bgc "';this.style.color='" self/color "'^" onmouseover=^"this.style.backgroundColor='" self/hbgc "';this.style.color='" self/hcolor "'^"" ] if use-onclick[ append blk [" onclick=^"" self/onclick "^"" ] ] append blk ">" ] ]