Thanks to Romano, Sterling, and Joel for the instant enlightenment

 
Sterling writes:
>  NOOOOOOOOOO!!!!
>  There is always a way not to do strings. :)
<snip>
> I hope this has helped you out.  If you have any more questions about
>  it, please ask... we all cringe here at REBOL HQ when we see the
>  unnecessary use of DO with strings..

Let me show you the depths of my ignorance, which might help
or inspire someone to write a best-downloading how-to on
Blocks and their uses.....

I hate to see a grown man cringe, so I'll close my eyes as I
write the next sentence.....

I almost always build a 'Layout as a string.

Why? Because building one with blocks seems to require
lots of special tricks.

There's a synthetic example below what I mean. It shows in
miniature the sort of things that happen if a 'Layout is made
up of loads of components sourced from different places
(user color choices from one file, screen metric
calculations from elsewhere, list of fields needed from a
CSV file, etc).

As a string, I can do it in moments, and get on with my life.
Blocks just seem too darned difficult in this instance.  But, as
I said last time, maybe it's not Rebol. Maybe it's my brain that's
at fault.

Colin
Rebol []

=========================================
;; 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
;; ================================

 makelayout: func [/local lay]
 [
 lay: join "across "
          [ " b: box "
            to-pair (MaxBoxWidth MaxBoxDepth)
            " "
             boxcolor
            " return "
            " c: box "
            to-pair (to-integer MaxBoxWidth / 2
                     to-integer MaxBoxDepth / 3)

             " "
             boxcolor
             "  + 150.150.150 "
             lastfield
             ": text {last field}"
          ]

 return lay
]


;; go do it
;; ========
 unview/all
 view layout load MakeLayout
=========================================
-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to