Printing out text of all GUI elements in Red language

114 Views Asked by At

I am trying to print out text from all GUI elements in following code:

  sentlist: ["A" "B" "C"]

  main: function [slist] [
      view collect [
          repeat i length? slist [
              keep compose [
                  text (slist/:i)
                  field "" 
                  return ]]
          keep [button "Printall" [
              repeat i (2 * length? slist)[
                  print face/parent/pane/(i)/text  ]]]]]

 (main sentlist) 

It runs all right without any error and text elements' text are properly printed out, but for fields, only last field's entry is printed out for each field. Where is the problem and how can it be corrected? Thanks for your help.

1

There are 1 best solutions below

5
On BEST ANSWER

In your spec field "" reuses the same string to each of the fields. Changing one field changes the text for each (likely for efficiency reasons, this is not reflected in the GUI). You could change the line to field (copy "") to provide a unique string.