Hi Richard,

Once upon a time Richard Boyd spoketh thus:
> The REBOL/Command User Guide page 8-29 states ..
> 
> --Forward References--
> "Sometimes a script needs to refer to a function before it has been 
> evaluated. This can be done as long as the variable for the function is 
> not evaluated before it is defined."
<..> 
> -------------- REFERENCE AFTER FAILS ------------------
> REBOL [Title: "Forward Reference"]
> 
> view layout
>    [banner "Forward Reference Test"
>    button "New Pane" [open-new-pane]]
>   
> open-new-pane: func
>    []
>    [view layout
>        [banner "New Window"
>        button "Quit" [quit]
>        button "Unview" [unview]]]
> --------------------------------------------------------------------

In your example, once the 'view function is reached, the value
of open-new has to be present, because part of the script _after_
view, are only reached after closing the view window.

e.g.:
--------- Script 1 ------------
REBOL[]

print 'before
view layout [ label "hi" ]
print 'after
-------- Script 1 -------------

If you run this script, first 'before is printed, _then_ the window
is opened, and 'after is only printed, if you close the window.

The proper way to forward reference for you would be to create a new
word holding the layout until it is viewed, like this:

-------- Script 2 -------------
REBOL []

lay: layout [
  banner "Forward Reference Test"
  button "New Pane" [open-new-pane]
]

open-new-pane: func [][
  view layout   [
    banner "New Window"
    button "Quit" [quit]
    button "Unview" [unview]
  ]
]

view lay
-------- Script 2 -------------

Now all functions are defined, before they are needed (evaluated) in
the 'view function.


I hope that clarifies it a bit.

Kind regards,


Ingo

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to