I am using following code to try to get GUI elements from a function:
mypanelfn: func[] [
collect[
repeat i 10 [
print append copy "i in loop: " i
keep [t: text] keep append copy "message: " i
keep [field "entry"
button "Click" [t/text: "clicked"] return]]]]
view [
do [mypanelfn]]
There are no error messages and loop go on all right and a windows is also displayed. But this is only a small empty windows without any text, fields or buttons.
What is wrong with this code?
Edit: putting probe
before collect
shows (I have added line breaks for clarity):
[t: text "message: 1" field "entry" button "Click" [t/text: "clicked"] return
t: text "message: 2" field "entry" button "Click" [t/text: "clicked"] return
t: text "message: 3" field "entry" button "Click" [t/text: "clicked"] return
t: text "message: 4" field "entry" button "Click" [t/text: "clicked"] return
t: text "message: 5" field "entry" button "Click" [t/text: "clicked"] return
once again; you need unique names for elements you want to address. Here a solution with reduce instead of compose
I recommend that you use the commands in the console to see what they do. E.g.
rejoin ['t i]
creates a string"t1"
with t and the (reduced/get-)value of i.to-word
changes that to a Red(bol) wordt1
to-setword tname
creates a set-wordt1:
to-set-path reduce [tname 'text ]
creates a set-patht1/text: