[REBOL] Re: How to make a layout from a block
From: brett:codeconscious at: 19-Apr-2002 20:26
> thanks for your suggestions.
> As this code is just the beginning test, how a
> small app to create a seat-plan could work, i have a some additional
Oh oh. :^)
> I improved my own code, but think it is not very elegant. I added two
> to to get the number of rows and columns to generate.
At this stage, I think you have gone the right way to build the layout block
> Your code only generates one seat, even if i click the button several
No, actually it produces a seat each time you click. The problem is
that they are all at the same position. This is because with make-face
you have to do more work. With layout the positioning is done for you.
This is why I mentioned offset. But no matter, now that you are using
a generated layout block there is no problem.
> seat must be adressable like "seat1" or "seat23" as well, but how can i
> implement that when the style is defined. There i just can define a
> not knowing the exact seat number?
Ok. Instead of using variables to name each seat, how about we define the
style to include a seat number. We can do this with the WITH statement. Also
the action should refer to FACE. FACE will be the seat that is clicked on.
Try these changes to your code (1) a seat-number variable is added to the
style itself (2) the action is changed to refer to FACE:
;--- defining seat style
saal-styles: stylize [
seat: box 6x6 green with [ seat-number: none ] [
Also you need this to set the seat-number. In this case I have used a pair
identify it - but naturally you can use whatever you like. Again I have used
WITH - this time to set seat-number of the face (our seat):
;--- Adding seats
repeat x quantity [
append main compose/deep [
seat with [seat-number: (to-pair reduce [x y])]
> Best wishes to the other side of this world.