Hi,
First, thanks
On Tue, Sep 16, 2014 at 6:30 PM, Offray Vladimir Luna Cárdenas <
offray(a)riseup.net> wrote:
Yes, is clearer. I would like to start with kind of a most basic browser,
to send information back and forward.
Consider this:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| browser dict |
dict := Dictionary new.
dict at: 1 put: 'uno'.
dict at: 2 put: 'dos'.
browser := GLMTabulator new
title: 'Minimal test'.
browser column: #keys; column: #values.
browser transmit
to: #keys;
andShow: [:k | k list display: #keys ].
browser transmit
from: #keys;
to: #values;
andShow: [:v | v text display: #value ].
browser openOn: dict
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Now I have a two panes browser trying to show pairs in a dictionary. In
fact, I said "trying" because I get the key twice. So my questions starting
from there are:
1. How to show in the #values column the values of the dict once you have
selected the specific key in the #keys column?
In the second transmission, you specify how to carry the value over to the
values pane and then you specify how to display the text. display: takes a
block. If you pass a symbol, it is equivalent to sending the unary message
to the entity object.
So, in your case, you can just do this:
| browser dict |
dict := Dictionary new.
dict at: 1 put: 'uno'.
dict at: 2 put: 'dos'.
browser := GLMTabulator new
title: 'Minimal test'.
browser column: #keys; column: #values.
browser transmit
to: #keys;
andShow: [:k | k list display: #keys ].
browser transmit
from: #keys;
to: #values;
andShow: [:v | v text display:* [ :key | dict at: key ]* ].
browser openOn: dict
Or you can work by passing around the association (so, an object that holds
more information and that does not require you to use the dict external
object).
| browser dict |
dict := Dictionary new.
dict at: 1 put: 'uno'.
dict at: 2 put: 'dos'.
browser := GLMTabulator new
title: 'Minimal test'.
browser column: #keys; column: #values.
browser transmit
to: #keys;
andShow: [:k |
k list
*display: [:d | d associations ];*
* format: [:assoc | assoc key asString]* ].
browser transmit
from: #keys;
to: #values;
andShow: [:v | v text display: *[ :assoc | assoc value asString ]*
].
browser openOn: dict
2. How to get any update in the #values column as an updated value in the
dictionary using ports and transformed messages.
In this case, you need an external object that will hold the side effect.
So, you can turn the first example into:
| browser dict |
dict := Dictionary new.
dict at: 1 put: 'uno'.
dict at: 2 put: 'dos'.
browser := GLMTabulator new
title: 'Minimal test'.
browser column: #keys; column: #values.
browser transmit
to: #keys;
andShow: [:k | k list display: #keys ].
browser transmit
from: #keys;
to: #values;
andShow: [:v | v text display: [ :key | dict at: key ] ].
*browser transmit *
* from: #values port: #entity;*
* from: #values port: #text;*
* when: [ :key :text | text notNil ];*
* to: #values port: #nirvana;*
* transformed: [ :key :text | dict at: key put: text ].*
browser openOn: dict
How is this?
Cheers,
Doru
--
www.tudorgirba.com
"Every thing has its own flow"