When to define words
[1/7] from: moeller_thorsten:gmx at: 9-Jul-2001 16:21
Hi,
i have layout with some fields to be filled. After filling a new layout is
called via a button. In a sub-layout of the second layout the content of the
fields should be displayed.
For some reasons i cannot find out, the input of the fields cannot be
accessed. The error says that the called word has no value.
In another sub-layout where i use the same word to generate a url i can
access the words value
Is there anybody who could explain this?
Thorsten
[2/7] from: brett:codeconscious at: 10-Jul-2001 0:31
Hi Thorsten,
It would really help if you could send a small example of your problem.
Brett.
[3/7] from: moeller_thorsten:gmx at: 9-Jul-2001 20:56
Hi Brett,
the code is something like the following:
layout2: layout [ H2 "second layout"
button "Sub" coal [sublayout/pane: sublayout-input show sublayout]
sublayout: box 300x300 coal
]
login: layout [ H2 "first layout"
label "Input: " myfield: field
button "go" [unview/all view layout2]
]
sublayout-input: layout [ H2 "Sublayout"
backcolor red
txt join "Input:" myfield/text
]
view login
In this sample i didn't get the error, but the sublayout didn't show the input as well.
Hope it comes clear what i was asking for.
Thorsten
[4/7] from: agem:crosswinds at: 9-Jul-2001 23:12
RE: [REBOL] Re: When to define words
[moeller_thorsten--GMX--De] wrote:
> Hi Brett,
> the code is something like the following:
<<quoted lines omitted: 13>>
> In this sample i didn't get the error, but the sublayout didn't show the input as well.
> Hope it comes clear what i was asking for.
yes. the point: the values are burned by layout and ignore later
changes. so do the layout after you know the value, not before.
or copy the values by hand (subfield/text: copy myfield/text).
:
[rebol []
layout2: [ H2 "second layout"
button "Sub" coal [sublayout/pane: LAYOUT sublayout-input show sublayout]
sublayout: box 300x300 coal
]
login: [ H2 "first layout"
label "Input: " myfield: field
button "go" [unview/all view layout layout2]
]
sublayout-input: [ H2 "Sublayout"
backcolor red
txt join "Input:" myfield/text
]
view layout login
]> Thorsten
[5/7] from: brett::codeconscious::com at: 10-Jul-2001 10:33
Hi Thorsten,
Comments below
> layout2: layout [ H2 "second layout"
> button "Sub" coal [sublayout/pane: sublayout-input show sublayout]
<<quoted lines omitted: 8>>
> txt join "Input:" myfield/text
> ]
When the Rebol interpreter has finished evaluating up to this point you will
have created a layout with a TXT on it
that has had it's /text already set - in fact to an empty string. What I
mean is, myfield/text has been evaluated - and it will not be evaluated
again.
> view login
>
> In this sample i didn't get the error, but the sublayout didn't show the
input as well.
You need some code that sets the TXT but only after the input has been
entered.
> Hope it comes clear what i was asking for.
I think so. So repeating myself you need something that will communicate the
user inputted text to the other sublayout.
One way would be to have one sublayout talk directly to the other. This
might be fine in a one off small program, but in a
bigger program it might be hard to understand what is happening.
Another way is to create a common point of reference for the two sublayouts
to access. Given that you user data is very likely to be used in other parts
of the program all you need is a global word or an object to set. Like this
; Somewhere to store our data
user-data: context [
user-input: none
]
layout2: layout [
H2 "second layout"
button "Sub" coal [
input-display/text: user-data/user-input
sublayout/pane: sublayout-input
show sublayout
]
sublayout: box 300x300 coal
]
login: layout [
H2 "first layout"
label "Input: " myfield: field [
; The user entered something - keep track of it
user-data/user-input: myfield/text
]
button "go" [unview/all view layout2]
]
sublayout-input: layout [
H2 "Sublayout"
backcolor red
input-display: txt join "Input:"
]
view login
That solve's the problem but for this example there is a little more we can
do.
For this example, sublayout-input doesn't change once it has the correct
input text set on it. So with that knowledge
we could create it only when we need it. Like this:
; Somewhere to store our data
user-data: context [
user-input: none
]
; A function to create the sublayout when needed
displaysub-layout2: does [
sublayout-input: layout compose [
H2 "Sublayout"
backcolor red
txt join "Input:" (user-data/user-input)
]
sublayout/pane: sublayout-input
show sublayout
]
layout2: layout [
H2 "second layout"
button "Sub" coal [ displaysub-layout2 ]
sublayout: box 300x300 coal
]
login: layout [
H2 "first layout"
label "Input: " myfield: field [
; The user entered something - keep track of it
user-data/user-input: myfield/text
]
button "go" [unview/all view layout2]
]
view login
So this bit of code shows how VID code can be treated as data to be
manipulated until you actually need it displayed.
And to make things clearer I've moved complex code out of the button into a
seperate function.
HTH
Brett.
[6/7] from: moeller_thorsten:gmx at: 10-Jul-2001 12:09
Hi Brett,
thanks for your detailed response.
One small question to your sample which works fine (only second one, first
has an error, but doesn't matter)!
Where in this code can i set the offset for the sublayout in your function?
Thorsten
-----Ursprüngliche Nachricht-----
Von: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]]Im Auftrag
von Brett Handley
Gesendet: Dienstag, 10. Juli 2001 02:34
An: [rebol-list--rebol--com]
Betreff: [REBOL] Re: When to define words
Hi Thorsten,
Comments below
> layout2: layout [ H2 "second layout"
> button "Sub" coal [sublayout/pane: sublayout-input show sublayout]
<<quoted lines omitted: 8>>
> txt join "Input:" myfield/text
> ]
When the Rebol interpreter has finished evaluating up to this point you will
have created a layout with a TXT on it
that has had it's /text already set - in fact to an empty string. What I
mean is, myfield/text has been evaluated - and it will not be evaluated
again.
> view login
>
> In this sample i didn't get the error, but the sublayout didn't show the
input as well.
You need some code that sets the TXT but only after the input has been
entered.
> Hope it comes clear what i was asking for.
I think so. So repeating myself you need something that will communicate the
user inputted text to the other sublayout.
One way would be to have one sublayout talk directly to the other. This
might be fine in a one off small program, but in a
bigger program it might be hard to understand what is happening.
Another way is to create a common point of reference for the two sublayouts
to access. Given that you user data is very likely to be used in other parts
of the program all you need is a global word or an object to set. Like this
; Somewhere to store our data
user-data: context [
user-input: none
]
layout2: layout [
H2 "second layout"
button "Sub" coal [
input-display/text: user-data/user-input
sublayout/pane: sublayout-input
show sublayout
]
sublayout: box 300x300 coal
]
login: layout [
H2 "first layout"
label "Input: " myfield: field [
; The user entered something - keep track of it
user-data/user-input: myfield/text
]
button "go" [unview/all view layout2]
]
sublayout-input: layout [
H2 "Sublayout"
backcolor red
input-display: txt join "Input:"
]
view login
That solve's the problem but for this example there is a little more we can
do.
For this example, sublayout-input doesn't change once it has the correct
input text set on it. So with that knowledge
we could create it only when we need it. Like this:
; Somewhere to store our data
user-data: context [
user-input: none
]
; A function to create the sublayout when needed
displaysub-layout2: does [
sublayout-input: layout compose [
H2 "Sublayout"
backcolor red
txt join "Input:" (user-data/user-input)
]
sublayout/pane: sublayout-input
show sublayout
]
layout2: layout [
H2 "second layout"
button "Sub" coal [ displaysub-layout2 ]
sublayout: box 300x300 coal
]
login: layout [
H2 "first layout"
label "Input: " myfield: field [
; The user entered something - keep track of it
user-data/user-input: myfield/text
]
button "go" [unview/all view layout2]
]
view login
So this bit of code shows how VID code can be treated as data to be
manipulated until you actually need it displayed.
And to make things clearer I've moved complex code out of the button into a
seperate function.
HTH
Brett.
[7/7] from: brett:codeconscious at: 10-Jul-2001 20:41
> One small question to your sample which works fine (only second one, first
> has an error, but doesn't matter)!
Oops. One small change before posting and I mess it up... :)
> Where in this code can i set the offset for the sublayout in your
function?
You could use the /offset refinement of the layout function and supply an
offset.
Or you could set the offset field of the face manually like this:
displaysub-layout2: does [
sublayout-input: layout compose [
H2 "Sublayout"
backcolor red
txt join "Input:" (user-data/user-input)
]
; position in bottom right corner
sublayout-input/offset: subtract sublayout/size sublayout-input/size
sublayout/pane: sublayout-input
show sublayout
]
Regards,
Brett
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted