Domanda

Ho il seguente script R3-GUI:

Rebol [
    file: %context.reb
]

either exists? %r3-gui.r3 [do %r3-gui.r3][load-gui]

view [
    title "First Window"
    hgroup [
        lab: label "fld 1 "
        fld1: field "Field Data 1"
    ]
    button "Display fld 1" on-action [if error? try [probe get-face fld1][alert "Can't read fld1"]]
    button "Display fld 2" on-action [if error? try [probe get-face fld2][alert "Can't read fld2"]]
    button "Open 2nd Window" on-action [
        view [
            title "Second Window"
            hgroup [
                label "fld 2" fld2: field "field 2 data"
            ]
            button "Display fld1" on-action [if error? err: try [probe get-face fld1][probe err alert "Can't read fld1"]]
            button "Display fld2" on-action [if error? err: try [probe get-face fld2][probe err alert "Can't read fld2" ]]
        ]
    ]
]
.

Quando faccio clic sul pulsante "Display FLD2" nella 2a finestra per accedere al contenuto di FLD2, sto ricevendo un errore ** Script error: fld2 word is not bound to a context.Qual è la causa di questo?E come posso accedere alla parola fld2 all'interno della seconda finestra?

È stato utile?

Soluzione 2

Il problema è derivante perché la funzione anonima che viene creata dalla funzione parse-layout dovrebbe essere una chiusura, e non lo è.Vedi il diff a https://gist.github.com/earl/a009454787D9FE4CFaca che risolve il problema.

Altri suggerimenti

Poiché FLD2 è locale a una funzione anonima e non legata al contesto utente

>> help win-face/facets/tab-face/actors 
WIN-FACE/FACETS/TAB-FACE/ACTORS is a block of value: [on-action make function! [[face arg
        /local fld2 err
    ][
        view layout [
            title "Second Window"
            hgroup [
                label "fld 2" fld2: field "field 2 data"
            ]
            button "Display fld 1" on-action [if error? try [probe get-face fld1] [alert "Can't read fld1"]]
            button "Display fld2" on-action [if error? err: try [probe get-face fld2] [probe err alert "Can't read fld2"]]
        ]
    ]]]
>>
.

funziona, se lo fai in questo modo

 l2: layout [
    title "Second Window"
    hgroup [
       label "fld 2" fld2: field "field 2 data"
    ]
    button "Display fld1" on-action [if error? err: try [probe get-face fld1][probe err alert "Can't read fld1"]]
    button "Display fld2" on-action [if error? err: try [probe get-face fld2][probe err alert "Can't read fld2" ]]
]


view  l1: layout [
   title "First Window"
   hgroup [
       lab: label "fld 1 "
       fld1: field "Field Data 1"
   ]
   button "Display fld 1" on-action [if error? try [probe get-face fld1][alert "Can't read fld1"]]
   button "Display fld 2" on-action [if error? try [probe get-face fld2][alert "Can't read fld2"]]
   button "Open 2nd Window" on-action [
      view l2
   ]
]
.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top