Was verursacht in diesem Skript den Fehler „Wort ist nicht an den Kontext gebunden“?

StackOverflow https://stackoverflow.com//questions/23039878

  •  21-12-2019
  •  | 
  •  

Frage

Ich habe das folgende R3-GUI-Skript:

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" ]]
        ]
    ]
]

Wenn ich im zweiten Fenster auf die Schaltfläche „Fld2 anzeigen“ klicke, um auf den Inhalt von fld2 zuzugreifen, wird eine Meldung angezeigt ** Script error: fld2 word is not bound to a context Fehler.Was ist die Ursache dafür?Und wie greife ich auf die zu fld2 Wort im zweiten Fenster?

War es hilfreich?

Lösung 2

Das Problem entsteht, weil die anonyme Funktion, die von erstellt wird parse-layout Funktion sollte ein Abschluss sein, und das ist nicht der Fall.Siehe den Unterschied unter https://gist.github.com/earl/a009454787d9fe4cfaca was das Problem behebt.

Andere Tipps

weil fld2 lokal für eine anonyme Funktion ist und nicht an den Benutzerkontext gebunden ist

>> 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"]]
        ]
    ]]]
>>

es funktioniert, wenn man es so macht

 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
   ]
]
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top