Little questions, big answers...
[1/17] from: allenk:powerup:au at: 7-Sep-2001 0:03
her suspect there is some way of avoiding the necessity of
> actually writing this out and then reading it back, but at least I have
> some confidence that that would work, and I can then work on improving
> the technique.
You can also write your layout block on the fly. Anton showed a way to add
created faces (using get-style) into a layout. An alternative is to output
the VID code for the required layout on the fly and then view it.
Although not everyone may "get" this example, it just shows that mixing
REBOL code and data as code is a fun and poweful way to create dynamic
layouts.
e.g..
names: ["John" "Fred" "Bill" "James" "Jenny"]
lay: copy [across]
; a reusable action block
press-action: [
; print the text value from the object next to me
probe get in first next find face/parent-face/pane :face 'text
]
foreach name names [
append lay compose [
button "Choose" press-action
text (name) return
]
]
; to see the VID dialect block we have generated
; probe lay
view layout lay
Cheers,
Allen K
Tomorrow I will post a demo for using Lists.
[2/17] from: dness:home at: 4-Sep-2001 15:48
Although I have considerable experience across a wide range of programming
languages, REBOL is different enough that learning it is a challenge. So far
it has been a very productive and worthwhile challenge, but `hard' nonetheless.
I have a few small fragments of code that
(a) work; and
(b) I don't understand at all (having cribbed them from some piece
or other of working code). I have the feeling that if I could gradually
understand them, I'd learn something about REBOL.
Here's an example. I have
dex-pane1: layout/offset [
origin 0 space 2x0 across
styles dex-styles
label right "IP Address" 200x24 bold middle font-size 16 return
IP-1: fld right return
IP-2: fld right return
IP-3: fld right return
IP-4: fld right return
IP-5: fld right return
] 0x0
which produces a panel in a display of IP addresses and Machine names.
What I am unclear about is at least:
(1) what _are_ `IP-1' ... here inside the layout. Are they `objects' created
by this declaration?
(2) Is there some way I can `dump' `IP-n' to take a look at what they are;
(3) My display obviously is `wired' to display 5 addresses. How would one normally
generalize this.
Although detailed programming advice is always welcome, I am more looking for (a few)
words about what is really `going on' in something like this `layout' declaration, if
that can be answered in less than a long epistle.
[3/17] from: carl:cybercraft at: 5-Sep-2001 8:39
On 05-Sep-01, David Ness wrote:
> Although I have considerable experience across a wide range of
> programming languages, REBOL is different enough that learning it is
<<quoted lines omitted: 22>>
> (1) what _are_ `IP-1' ... here inside the layout. Are they
> `objects' created by this declaration?
They're variables referencing the fld objects.
> (2) Is there some way I can `dump' `IP-n' to take a look at what
> they are;
Yes, but there's a lot to them. For instance...
>> view layout [IP-6: field "Hello"]
gives you a field which I assume is much like in your example. Now,
to see all the variable names in the field object, enter the
following at the Console (after you've closed the window created by
the above) ...
>> probe first ip-6
(Don't enter just "probe ip-6" though, as REBOL will go away for a
very long time...)
This gives you...
[self type offset size span pane text color image effect data edge
font para feel saved-area rate show? options parent-face old-offset
old-size line-list changes face-flags action state style alt-action
facets related words colors texts file var keycode reset styles init
multi blinker pane-size dirty? help user-data flags]
These can be accessed thus...
>> ip-6/text
== "Hello"
>> ip-6/size
== 200x24
>> ip-6/colors
== [240.240.240 255.255.100]
and so on. The following uses the ip-6 vaiable to clear the field's
text by clicking on a button.
view layout [IP-6: field "Hello" button "Clear" [clear ip-6/text show
ip-6]]
Hope this helps. Others will be better qualified to answer the next
question. (We're mostly all learners when it comes to View/VID.:)
> (3) My display obviously is `wired' to display 5 addresses. How
> would one normally generalize this.
> Although detailed programming advice is always welcome, I am more
> looking for (a few) words about what is really `going on' in
> something like this `layout' declaration, if that can be answered in
> less than a long epistle.
--
Carl Read
[4/17] from: ryanc:iesco-dms at: 4-Sep-2001 13:47
David Ness wrote:
> Although I have considerable experience across a wide range of programming
> languages, REBOL is different enough that learning it is a challenge. So far
<<quoted lines omitted: 19>>
> (1) what _are_ `IP-1' ... here inside the layout. Are they `objects' created
> by this declaration?
The object is going to be there no matter what, it lives in the pane property. Assignment
here just allows you to use that name to access it, like all assignments in rebol.
> (2) Is there some way I can `dump' `IP-n' to take a look at what they are;
Well I you can mark the fields in stylize (use user-data property I think, but you
probably can add about any name). Then you can loop thru the panes to see which one
is
marked, dumping the value.
> (3) My display obviously is `wired' to display 5 addresses. How would one normally
> generalize this.
Build your layout by hand. You can build it at the pane level, or just compose your
own
layout script on the fly.
>
> Although detailed programming advice is always welcome, I am more looking for (a few)
> words about what is really `going on' in something like this `layout' declaration,
if
> that can be answered in less than a long epistle.
Try:
>> source layout
>
> --
> To unsubscribe from this list, please send an email to
> [rebol-request--rebol--com] with "unsubscribe" in the
> subject, without the quotes.
--
Ryan Cole
Programmer Analyst
www.iesco-dms.com
707-468-5400
[5/17] from: jelinem1:nationwide at: 4-Sep-2001 16:27
Back from "out of the office". Sorry about the spam. I've given Lotus
Notes a good spanking over it.
Following is a function I've found useful for viewing blocks and objects.
Even though 'mold will usually work good enough, the following 'display
function is most useful for viewing those self-referential objects. This
should provide a clearer view of the VID objects that you define. I hope
it doesn't line-wrap too badly.
;---------------------------------------------------------------------------------
display: function [
"View the contents of a word"
some-thing "Thing to print"
/mold "Mold the values to display"
/assoc "Print the elements of an associative list"
num-elem [integer!] "Number of elements to associate"
/verbose
][sep idx][
sep: ""
if verbose [print ["- This is of type:" type? :some-thing]]
switch/default type?/word :some-thing [
object! [
if verbose [print "--- Thing is an object"]
foreach some-word next first some-thing [
system/words/print either mold [
[some-word ":^(tab)" system/words/mold get (in some-thing
some-word)]
][ [some-word ":^(tab)" get (in some-thing some-word)] ]
]
]
block! [
if verbose [print "--- Thing is a block"]
either assoc [
idx: make counter [value: 0]
forall some-thing [
idx/inc
prin [idx/value ")^(tab)"]
loop num-elem [
system/words/prin sep sep: " - "
system/words/prin either mold [
system/words/mold first some-thing
][ first some-thing ]
some-thing: next some-thing
]
system/words/print ""
some-thing: back some-thing
]
][
repeat idx length? some-thing [
system/words/print either mold [
reduce [idx ")^(tab)" system/words/mold pick some-thing idx]
][ reduce [idx ")^(tab)" pick some-thing idx] ]
]
]
]
][
if verbose [print "--- Thing is a default"]
system/words/print either mold [system/words/mold
some-thing][some-thing]
]
exit
]
[6/17] from: dockimbel:free at: 5-Sep-2001 12:13
Hi David,
David Ness wrote:
[...]
> dex-pane1: layout/offset [
> origin 0 space 2x0 across
<<quoted lines omitted: 6>>
> IP-5: fld right return
> ] 0x0
[...]
> (2) Is there some way I can `dump' `IP-n' to take a look at what they are;
AFAIK, there're 2 easy and safe ways to get more info on VID face objects :
>> dump-face IP-1
and
>> help IP-1 ; if you have my %help.r script.
HTH,
DocKimbel.
[7/17] from: dness:home at: 5-Sep-2001 10:06
My thanks for several pieces of prompt and substantial help. I find
the various suggestions about how I can view REBOL objects useful
not only here, but in other contexts as well.
I am still having a problem getting a grip on what exactly my
layout [ ...
IP-1: field ...
]
is, (i.e. is this something I can `set', and what kind of a thing is `field'
can I `do' this in an executable loop) but I am making some progress as I dig in.
Thanks again to those who have helped/are helping.
[8/17] from: matt:blis at: 5-Sep-2001 15:25
David Ness <[DNess--Home--Com]> wrote on 05/09/01 15:06:45:
>My thanks for several pieces of prompt and substantial help. I find
>the various suggestions about how I can view REBOL objects useful
<<quoted lines omitted: 6>>
>can I `do' this in an executable loop) but I am making some progress as I dig in.
>Thanks again to those who have helped/are helping.
AFAIK (but I'm new to View) is that field is comparable to an HTML text input field.
Matt.
[9/17] from: dness:home at: 5-Sep-2001 11:34
Matt Burns wrote:
> AFAIK (but I'm new to View) is that field is comparable to an HTML text input field.
>
Thanks for the try, but I'm afraid `comparable' isn't a word I understand in this context.
Obviously you don't mean that REBOL `executes' <HTML>, or that my statement `asks' for
input (it doesn't), so what do _you_ mean by `comparable'?
[10/17] from: arolls:bigpond:au at: 6-Sep-2001 2:03
Layout is just a function that returns a face.
Its argument is a block.
Layout looks in the block and interprets it
in its own way. (ie. The layout dialect).
Field (and others, like button) only have a meaning
in the context of a block passed to layout (by
default, anyway).
Layout sees "field" and adds a new subface to the
face it is preparing to return to you.
A face can be a container of many subfaces.
The subfaces are called "panes" in rebol
terminology.
The panes are stored in an attribute of the face;
pane
(makes sense, in the real world, panes are
smaller parts of a window in a house).
Actually, a face is really just a rebol object
with a whole lot of attributes set up.
Attributes are just words inside the object.
This is how to refer to an attribute of a face
produced by layout:
lay: layout [field]
Here, lay is set to the face that layout returns.
Let us look in the face:
probe first lay
== [self type offset size span pane text color image effect
data edge font para feel saved-area rate show? options
parent-face old-offset old-size line-list changes
face-flags action state style alt-action facets related words
colors texts file var keycode reset styles init multi
blinker pane-size dirty? help user-data flags parent]
(The first item in an object is the list of words
defined in it.)
We get a big list of words.
Interesting ones are:
lay/self
refers to itself (hence lay/self == lay )
lay/type
== face
tells you this object is a face
lay/style
== none
(boring this time, but tells you which vid style it is, see below)
length? lay/pane
== 1
tells you there is one subface in our layout.
lay/pane/1/style
== field
It's a field! (as we defined at the beginning).
And there are other interesting ones too.
Layout's dialect also allows setting of words.
It sees a set-word! notation, such as "IP-1:"
and sets it to the face it is creating.
This word "IP-1" is accessible outside the layout block.
It basically points to the face object that has been
created.
Pane/1, in the containing face returned by layout,
also points to that face. (lay/pane/1 == IP-1)
So the layout block is a little bit special.
You can't do normal rebol code in it.
Well, you can, actually, but you have to do it
the layout dialect way! :)
layout [do [some code]]
That can be quite useful sometimes.
Anyway... I am not sure I am answering your questions.
[11/17] from: dness:home at: 5-Sep-2001 12:18
Anton wrote:
> Layout is just a function that returns a face.
>
> Its argument is a block.
>
...
[snip of an _extremely_ useful answer]
Your long, and thought provoking, answer looks like it will be _extremely_ helpful to
me.
Thank you for taking the time to write it. I'll get back, perhaps with some questions,
after
I have had a chance to study it in detail later today.
Thanks again!
[12/17] from: matt:blis at: 5-Sep-2001 19:30
David,
> >
> > AFAIK (but I'm new to View) is that field is comparable to an HTML
<<quoted lines omitted: 4>>
> REBOL `executes' <HTML>, or that my statement `asks' for
> input (it doesn't), so what do _you_ mean by `comparable'?
I only meant that (as with HTML input fields) it doesn't *have* to take
input, but it allows you to if you need to, and reserves space to do so.
As it is, I'm still trying to get to grips with REBOL after being away
for a while, and now I find REBOL/View has made an appearance. Looks
like I may get more involved in this than I realised...
Matt.
[13/17] from: dness:home at: 5-Sep-2001 14:57
Anton wrote:
[snip of answer]
> That can be quite useful sometimes.
> Anyway... I am not sure I am answering your questions.
>
You did. And it was a very nice and clear explanation too.
Whether I am up to being able to _do_ something with it is now
up to me, at least you have provided me with enough understanding
so that I have some ideas that I can try.
Thank you for your time.
[14/17] from: carl:cybercraft at: 6-Sep-2001 8:28
On 06-Sep-01, David Ness wrote:
> My thanks for several pieces of prompt and substantial help. I find
> the various suggestions about how I can view REBOL objects useful
<<quoted lines omitted: 6>>
> `field' can I `do' this in an executable loop) but I am making some
> progress as I dig in.
Have you seen the View Developer's Guide? Found here...
http://www.rebol.com/docs.html
More just a start than the last word on View, but if you haven't seen
it it should answer some of your questions. (As I'm sure Anton's nice
reply has.)
> Thanks again to those who have helped/are helping.
--
Carl Read
[15/17] from: dness:home at: 5-Sep-2001 17:39
Carl Read wrote:
> Have you seen the View Developer's Guide? Found here...
> http://www.rebol.com/docs.html
<<quoted lines omitted: 3>>
> --
> Carl Read
Thanks. I had passed through it once, but now with Anton's reply above I find
I understand it better. So far it has allowed me to dramatically simplify things,
and I am left with one principal problem: how to get a number (variable from
one run to another, but fixed for each run) of `field' commands executed
_inside_ a layout.
I think I am now in a situation where I can see my way clear to solving my
experimental problem by writing out a layout command into a text file which I
then `do'. I rather suspect there is some way of avoiding the necessity of
actually writing this out and then reading it back, but at least I have
some confidence that that would work, and I can then work on improving
the technique.
[16/17] from: arolls:bigpond:au at: 6-Sep-2001 20:20
I thought you wanted to do that!
I don't recommend writing a file.
That's more work than necessary.
lay: layout [size 300x300]
repeat n 10 [
append lay/pane make get-style 'field compose [
offset: (n * 10x28)
text: (join "field" n)
]
]
view lay
To see how this works, you will need to know how
make, compose and get-style work. But here is an
example of the above that requires more manual
labour.
lay: layout [size 300x300]
append lay/pane make get-style 'field []
lay/pane/1/offset: 10x10
view lay ; now close the window
append lay/pane make get-style 'field []
lay/pane/2/offset: 20x40
view lay
Get-style takes a word like 'field and returns
you a pointer to the default, "archetype", field face
that is set up by rebol VID.
Make makes a copy of that object so we have our own.
Without make there, we would be modifying one face,
and appending it multiple times to the pane list.
You can do it, but they will all have the same
position, size, text, etc. which will cause you
problems.
There is also list.
view layout [list [field] data [["hello"] ["there"]]]
This requires a bit of work to set up and
manipulate, but there are docs lying around.
[17/17] from: dness:home at: 6-Sep-2001 9:33
Anton wrote:
> I thought you wanted to do that!
> I don't recommend writing a file.
<<quoted lines omitted: 31>>
> This requires a bit of work to set up and
> manipulate, but there are docs lying around.
This is another very useful answer, which leaves me dangerously close to
thinking I actually understand what is going on!
Last night I implemented the write file/read file solution, and it works quite
well, and it has the advantage ob being (conceptually) almost simple and applicable
to problems that arise in other context.
However, I will try the approach you suggest as it is clear to me I will learn
something by doing so.
Thanks again for you effort and help.
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted