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

Newbie: need help with COMPOSE

 [1/4] from: apwing::zonnet::nl at: 13-Oct-2003 12:26


Hi list, below a extracted piece of program containing 2 times a "do rejoin". I tried hard to not use rejoin, but compose instead, but it did'nt work out properly. Could you show me how to rewrite the code in both cases? Thanks in advance, Arie van Wingerden http://home.zonnet.nl/rebolution ;;; ========================= Code follows here REBOL [] ; ; This function extends a 2nd level object with a function ; add-affix-func: does [ do rejoin [ "rules/" fxname ": " "make rules/" fxname " [ " ; Extend 2nd level object "rule" fxcount ": func" ; Function name "[ inword [ string! ] ]" ; Function spec block "[ print 200 ]" "]" ] ] ; ; Main program starts here ; fxname: "A" ; name of 2nd level object fxcount: 1 ; counter rules: make object! [] ; create 1st level object do rejoin [ "rules: make rules [" ; create 2nd level object fxname ": make object! [ x: 100 ]]" ] probe rules ; show intermediate result input ; pause console add-affix-func ; extend 2nd level object probe rules ; show final result input ; pause console

 [2/4] from: lmecir:mbox:vol:cz at: 13-Oct-2003 13:34


Hi Arie, ----- Original Message ----- From: "Arie van Wingerden"
> Hi list, > below a extracted piece of program containing 2 times a "do rejoin".
<<quoted lines omitted: 32>>
> probe rules ; show final result > input ; pause console
I (and the documentation) suggest you to avoid doing strings. Try the code below: add-affix-func: has [fxn] [ fxn: in rules fxname set fxn make get fxn compose [ (to set-word! join "rule" fxcount) ; Function name func [inword [string!]] ; Function spec block [print 200] ] ] fxname: 'A ; name of 2nd level object fxcount: 1 ; counter rules: make object! [] ; create 1st level object rules: make rules compose [ ; create 2nd level object (to set-word! fxname) make object! [x: 100] ] probe rules ; show intermediate result ; input ; pause console add-affix-func ; extend 2nd level object probe rules ; show final result ; input ; pause console -L

 [3/4] from: ingo:2b1 at: 13-Oct-2003 13:22


Hi Arie, this doesn't look like the most elegant way to do it to me, but it works ... ;--- start script --- [REBOL [] ; ; This function extends a 2nd level object with a function ; add-affix-func: func [ /local fxn "don't know, wether you need fxname to be a string ..." ] [ fxn: to-word fxname do compose/deep [ (to-set-path compose [rules (fxn)]) make (to-path compose [rules (fxn)]) [ (to-set-word join 'rule fxcount) func [ inword [string!] ][ print 200 ] ] ] ] ; ; Main program starts here ; fxname: "A" ; name of 2nd level object fxcount: 1 ; counter rules: make object! [] ; create 1st level object do probe compose/deep [ rules: make rules [ ; create 2nd level object (to-set-word fxname) make object! [ x: 100 ]] ] probe rules ; show intermediate result ;input ; pause console add-affix-func ; extend 2nd level object probe rules ; show final result ;input ; pause console ] Arie van Wingerden wrote:

 [4/4] from: apwing:zonnet:nl at: 13-Oct-2003 14:17


Hi Ingo and Ladislav, thanks for the code! It greatly helps me further on the subject. Thanx again, Arie

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