|
Pages: [1]
|
 |
|
Author
|
Topic: building layout/view dynamically (Read 593 times)
|
|
gabrielcrowe
|
first post, from an excited vbscript refugee.
i'v had a search, and a poke around at various pieces of source, but this one is killing me.
i can load files from disk and such, csv, in this case. and i can build a gui by hand, a static one, thats not a problem. what i really would like to do is use the data from a text file to position buttons and to assign them functions. their labels, colours and such, should all be defined from the txt file.
i tried to do some magic from inside the view[] but it errors every time, a simple array loop would do it, but..always an error.
is what i need actually possible? :huh:
thanks for your time everyone.
|
|
|
|
|
Logged
|
|
|
|
|
Graham
|
A vid layout is dynamically constructed!
If you have a VID layout as a file, you can try something like this
; read it in first lo: read %mylayout.r
; convert to block so it can be parsed lo: to-block lo
; now bind it so that Rebol understands what context the words are to be interpreted ; let's bind it to layout
bind lo 'layout
; now you can do this
view layout lo
; untested and hope it helps.
|
|
|
|
|
Logged
|
|
|
|
|
Gabriele
|
Graham, in that case, just do: view layout load %mylayout.r But I think he's asking for something different. gabrielcrowe, you may either need COMPOSE or doing something like: lay: copy [ ; any initial VID code before the buttons you are adding ] foreach [text size] ["One" 100 "Two" 200 "Three" 110] [ append lay compose [btn (text) (size)] ] view layout lay
Basically you just build the layout block by appending code to it (or manipulating it in any other way - it's just a block), then call LAYOUT on it.
|
|
|
|
|
Logged
|
|
|
|
|
gabrielcrowe
|
spot on, and both raised some interesting ideas. REBOL [] defaultdata: read/lines %default.txt lay: copy [
]
foreach datarow defaultdata [ parsed-block: parse datarow "#" foreach [text size] [parsed-block] [ append lay compose [btn (text) (size)] ] ]
view layout lay my file default.txt contains: "buttonname1"#100 "buttonname2"#300 "buttonname3"#200 it makes 3 buttons i'm assuming them to be the rows in my txt, but how do i split the rows up for use in the building of the buttons. lol, this is all very confuddling. but fun, nonetheless.
|
|
|
|
« Last Edit: August 08, 2006, 06:38:25 AM by gabrielcrowe »
|
Logged
|
|
|
|
|
gabrielcrowe
|
i also tried this: REBOL [] defaultdata: read %default.txt
lay: copy [
]
foreach [text size] [defaultdata] [ append lay compose [btn (text) (size)] ]
view layout lay with my txt as this: "One" 100 "Two" 200 "Three" 110 no dice. i think perhaps i dont understand how to use blocks. lol.
|
|
|
|
|
Logged
|
|
|
|
|
Graham
|
defaultdata: to-block read %default.txt
otherwise it's a string ...
|
|
|
|
|
Logged
|
|
|
|
|
gabrielcrowe
|
nope, i tried that, and i get an error about it being 'none'
Unrecognized parameter: none
it draws a single button, thats all.
|
|
|
|
|
Logged
|
|
|
|
|
Philippe
|
Hello, The problem comes from your code : you use a foreach loop with [defaultdata] (block!), no defaultdata. Try this, it works, with default.txt like this : "buttonname1" 100 "buttonname2" 300 "buttonname3" 200 defaultdata: load %default.txt
lay: copy []
foreach [text size] defaultdata [ append lay compose [btn (text) (size)] ]
view layout lay
===Philippe
|
|
|
|
|
Logged
|
===Philippe
|
|
|
|
|
Pages: [1]
|
|
|
 |
News: 01-09-08 Alpha version of REBOL 3 has been released!
2240 Posts in 584 Topics by 2210 Members
Latest Member: Wqmsewzb
|