Rebol Talk Forum  |  REBOL Discussions  |  REBOL View  |  Topic: Generating labels in loop
Pages: [1] Print
Author Topic: Generating labels in loop  (Read 356 times)
Tailcat
Guest


Email
Generating labels in loop
« on: January 27, 2006, 12:50:30 AM »

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
Full Member
***
Offline Offline

Posts: 113


View Profile
Re: Generating labels in loop
« Reply #1 on: May 03, 2006, 04:41:57 AM »

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] Print 
Rebol Talk Forum  |  REBOL Discussions  |  REBOL View  |  Topic: Generating labels in loop
Jump to:  

  
Quick Search...

Advanced search
  
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 21, 2008, 06:21:28 AM
Username: Password: Session Length:
  

News: 01-09-08

Alpha version of REBOL 3 has been released!


  
2290 Posts in 593 Topics by 3742 Members
Latest Member: CorHorgeExpex

  Rebol Talk Forum | Powered by SMF 1.0.9.
© 2001-2005, Lewis Media. All Rights Reserved.

RT design by Defiant Pc