Hi Philippe,

I have made a working example of code similar to yours:

    inform-disp: copy []
    for e 1 6 1 [
        text: join "text" e
        coor: to-pair reduce [70 * e + 243 107]
        append inform-disp compose [
            at (coor) (to-set-word join 'fldmodif e) field 40x22 (text)
        ]
    ]
    view layout inform-disp

But you wrote that some fields may/may not be created. So how will you know
which exists or not? Here is an example (not good though - read below):

    inform-disp: copy []
    for e 1 6 1 [
        text: join "text" e
        coor: to-pair reduce [70 * e + 243 107]
        if not equal? 1 random 4 [
            append inform-disp compose [
                at (coor) (to-set-word join 'fldmodif e) field 40x22 (text)
            ]
        ]
    ]
    append inform-disp [
        at 10x120
        button "Print fields" [
            for e 1 6 1 [
                if value? fld-name: to-word join 'fldmodif e [
                    fld: get fld-name
                    print fld/text
                ]
            ]
        ]
    ]
    view layout inform-disp

There is a problem with this. The fldmodif1, fldmodif2... words are global.
So if you run the code again in the same
session you will not get the correct results.

Here is another way. This way does not use field names - it uses a field
called "TAG" that every face has. You can put
any value you want into tag. In this example I create a new field type
called special-fld. It has an action that will print
the field that was just changed.

    inform-disp: copy [
        style special-fld field 40x22 [
            print [
                "Field" face/tag
                "at position" face/offset
                " has value" mold value
            ]
        ]
        text "type in the fields"
    ]
    for e 1 6 1 [
        text: join "text" e
        coor: to-pair reduce [70 * e + 243 107]
        append inform-disp probe compose/deep [
            at (coor) special-fld with [tag: (e)] (text)
        ]
    ]
    view layout inform-disp

Hope it helps you.
Brett.

----- Original Message -----
From: "Philippe Oehler" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, January 11, 2002 8:50 PM
Subject: [REBOL] Compose iterated fields with different names for each


> I composed a part of a layout with different fields.
> Those fields are produced if a condition is true. So that's why I want a
> name for each of them.
> The names should be fldmodif1, fldmodif2, fldmodif3, etc., to see if the
> user change them when he will press a button.
>
> I used the append exemple-layout REDUCE COMPOSE/DEEP to make it in a
boucle
> of 'for.
>
> Like that :
>
> for e 1 6 1 [
>      text8: join first tran ["-" ghi]
>     coor: 243 + (70 * e) coor: to-pair (join coor "x107")
>      append inform-disp reduce compose/deep ['at (coor) fldmodif1: 'field
> 40x22 (text8)]
> ]
>
> You noticed that it that example the name is fldmodif1. But i cant, using
> reduce compose/deep, produce a fldmodif (e) without having an error.
>
> I tried to produce a string first and then append it to the inform-box.
But
> it doesnt work too.
>
>  text567: join "at " [coor " fldmodif" e ": field 40x22 " text8]
>  print text567
>  append inform-disp reduce compose/deep [(text567)]
>
> How can i make it ??
>
>
> Philippe Oehler
>
> --
> To unsubscribe from this list, please send an email to
> [EMAIL PROTECTED] with "unsubscribe" in the
> subject, without the quotes.
>

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

Reply via email to