|
Pages: [1]
|
 |
|
Author
|
Topic: Generating labels in loop (Read 323 times)
|
Tailcat
Guest
|
Dear all,
I am trying to generate a layout woith a variable number of labels (and fields) based on the value of a variable.
I can write the code explicitly, but whenever I try to put it in a loop I get an error upon trying to `load' the code.
The code is as follows:
REBOL [Title: "Problem Testing"] x_dim: 3 ; incoming variable that dictates number of labels needed i: 1 x0: [1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0]
mk_str: func [ pre i] [append pre to-string :i] x0: layout [ style lab label 100 right across ; Cannot get this loop to work repeat i x_dim compose/deep copy/deep [ lab (mk_str "dim_" (1)) ; Error indicated here field [x0/i: value] return ] ; the reported error message (On trying to load the code via "do %file.r") ; ** Script Error: lab has no value ; ** Where: do-facets ; ** Near: lab "dim_1" ; field [x0/i: value] return ; This approach does not work either ;foreach i [1 2 3] compose/deep [ ; lab (mk_str "dim_" (i)) ; field [x0/i: value] return ; ]
; the following seems to work perfectly lab mk_str "dim_" 1 field [x0/1: value] return lab mk_str "dim_" 2 field [x0/2: value] return lab mk_str "dim_" 3 field [x0/3: value] return lab space 0 button "Enter" [print x0/1 print x0/2 print x0/3 unview/only x0 ] button "Cancel" [unview/only x0] ] view x0 ;mk_str "SS_" 4
|
|
|
|
|
Logged
|
|
|
|
|
Graham
|
I have not looked at your code closely, but the glaring error I can see is that you are trying to use rebol code inside the layout. The layout takes a dialect, and not Rebol code.
|
|
|
|
|
Logged
|
|
|
|
|
|
Pages: [1]
|
|
|
 |