[REBOL] Re: Create words dynamically
From: greggirwin:mindspring at: 5-Mar-2006 13:22
Hi Thorsten,
TM> How can i create words dynamically from the content of a block and use
TM> these words for filling them up with new content like this:
TM> words: [ "phhtmcl" "phhocml" ]
TM> content: [ "phhtmcl/111" "phhocml/222" "phhtmcl/333" "phhocml/444"]
...
TM> These words should be filled with with an other foreach loop on the
TM> content-block, where the first part is the indicator in which word the
TM> content should stored an the second one ist the content itself. how can
TM> i use these created words in the following scriptparts?
Something like this?
>> words: [ "phhtmcl" "phhocml" ]
== ["phhtmcl" "phhocml"]
>> content: [ "phhtmcl/111" "phhocml/222" "phhtmcl/333" "phhocml/444"]
== ["phhtmcl/111" "phhocml/222" "phhtmcl/333" "phhocml/444"]
>> foreach word words [set to word! word copy []]
== []
>> foreach cmd content [word-val: parse cmd "/" append get to word! first word-val load
seco
nd word-val]
== [222 444]
>> phhtmcl
== [111 333]
The long line that parses the command and loads the data will no doubt
need some tuning, and would benefit from being broken apart, but you
get the idea.
Now, what I have to ask is: What is the real goal and use? I know if
often seems easy to expose REBOL, load files and just DO them. If
that's the case, then why the string formats? If the goal is for users
to create files that make the app more dynamic, why not use a dialect?
-- Gregg