如何从 Red 语言的面板访问值

How to access values from panels in Red language

我正在使用以下代码查找 2 个数字系列的乘积,然后计算这些乘积的总和:

  make-row: func [][
    compose [
        t1: text "N1:"
        f1: field 
        t2: text "N2: "
        f2: field
        t3: text "Product: "
        t4: text ""
        b: button "Get product" [
            x: face/extra/2/text          
            y: face/extra/4/text
            z: (to-integer x) * (to-integer y)
            face/extra/6/text: rejoin [z]]
        do [b/extra: reduce [t1 f1 t2 f2 t3 t4]] ]  ]

  view compose [
        (make-row) return 
        (make-row) return
    b: button "Calculate" [t2/text: "..to be given"]
    t1: text "Sum of products:"
    t2: text ""                       ; NEED TO GET SUM OF ALL PRODUCTS IN ABOVE ROWS. 
  ]  

第一部分工作正常 - 产品计算正确。但是我怎样才能访问这些单独的产品来找到产品总和呢?我找不到任何方法,因为这些行不是真正的对象,我可以访问其 public 变量或 methods/functions 。如何解决?感谢您的帮助。

因为我刚刚了解了面孔和窗格,这里有一个没有错误处理的解决方案

make-row: func [][
     compose [
        text "N1:"
        field 
        text "N2: "
        field
        text "Product: "
        text ""
        button "Get product" [
            b1: index? find face/parent/pane  face
            face/parent/pane/(b1 - 1)/text:  form multiply   to-integer   face/parent/pane/(b1 - 5)/text  to-integer face/parent/pane/(b1 - 3)/text  
        ]

    ]  
]
view compose [
    (make-row) return 
    (make-row) return
    button "Calculate" [
        t2/text:   form add to-integer face/parent/pane/6/text  to-integer face/parent/pane/13/text
    ]
    text "Sum of products:"
    t2: text ""  
]   

所有人脸对象都在父人脸的窗格块中排序。因此,查看被单击的人脸对象的索引,您可以获得计算其他人脸对象位置的参考。