[REBOL] Re: To do or not to do?
From: rotenca:telvia:it at: 29-Nov-2001 2:39
Hi,
things are more simple of what you think. I have only removed the string and
the function and (almost) everything works as you want.
The only differences are:
1)
a: 300
b: 1
to-pair (a b) gives 1x1
because (a b) is = 1
try it on the console (the best friend of rebol programmer)
a right mode is:
to-pair reduce [a b]
2)
Another problem is that zz: will be a global word; to-set-word changes the
binding of the word and transform it in a global word. If zz: must be local
the code requires some little changes.
3) you can use compose or a combination of insert/append
;; layout we want to achieve:
;; ========================
Wanted: [across
b: box 99x100 green
Return
c: box 45x33 green + 150.150.150
zz: text "last field"
]
;; Various bits of derived data needed
;; ===================================
MaxBoxWidth: 99
MaxBoxdepth: 100
BoxColor: Green
LastField: 'zz
;; A function to do it with strings
;; ================================
; a way with compose
lay: compose [
across
b: box to-pair reduce [MaxBoxWidth MaxBoxDepth] boxcolor
return
c: box to-pair reduce [to-integer MaxBoxWidth / 2 to-integer MaxBoxDepth / 3]
boxcolor + 150.150.150
(to-set-word :lastfield) text {last field}
]
;another way with insert/append
lay: append [
across
b: box to-pair reduce [MaxBoxWidth MaxBoxDepth] boxcolor
return
c: box to-pair reduce [to-integer MaxBoxWidth / 2 to-integer MaxBoxDepth / 3]
boxcolor + 150.150.150
] head insert [text {last field}] to-set-word :lastfield
;; go do it
;; ========
unview/all
view x: layout lay
---
Ciao
Romano