Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: adding line hints when building blocks

From: carl:cybercraft at: 25-May-2002 16:55

Hi Gregg, I've got close to what you want by using a "do string" to create a template for your files. This at least means you only have to do a string once. ie... ---8<--- rebol [] template: do "[^/none[^/value none^/mail none^/]^/]" file: [] insert file copy/deep template file/1: 'item-1 file/2/2: 1 file/2/4: [foo--bar--com] insert file copy/deep template file/1: 'item-2 file/2/2: 2 file/2/4: [foo--baz--com] insert file copy/deep template file/1: 'item-3 file/2/2: 3 file/2/4: [foo--bat--com] sort/skip file 2 ; (; print mold file ---8<--- This gives...
>> do %test.r
[item-1 [ value 1 mail [foo--bar--com] ] item-2 [ value 2 mail [foo--baz--com] ] item-3 [ value 3 mail [foo--bat--com] ]] It's not quite perfect as line-hints for the item values are lost when you change them, ((because they're in the outer block, perhaps?), but the others are kept so it's almost how you wanted it. This is how the file would look with no values changed...
>> blk: [] loop 3 [insert blk copy/deep template] print mold blk
[ none [ value none mail none ] none [ value none mail none ] none [ value none mail none ]] So close. Grrr! (: Hope that gets you some way to where you want, anyway. Carl. On 25-May-02, Gregg Irwin wrote:
> hi Ammon, > << Just a shot in the dark (I am still not sure what you are > attempting, an example maybe?) Have you tried placing the word > 'newline in where you wanted > a new line? and I think that there is a similar one for tab IIRC. >> > Yup. Tried various combinations of things, reducing, composing, etc. > but no luck so far. > The goal is to write out, to a file, something like this: > item-1-id [ > value 0 > mail [foo--bar--com] > ] > item-2-id [ > value 1 > mail [foo--baz--com] > ] > which is an easy format to create and edit manually, and also very > easy to just LOAD for use in scripts. The format you get without > line hints is much harder to work with manually. E.g. > item-1-id [value 0 mail [foo--bar--com]] item-2-id [value 1 mail > [foo--baz--com]] item-3-id [value 1 mail [foo--baz--com]] item-4-id [value 1 > mail [foo--baz--com]] item-5-id [value 1 mail [foo--baz--com]] > The new serialized format will be fine for apps you don't want to > edit manually, and for REBOL developers, but for the average joe > (script-tinkerer, help-desk personnel), I think the native block > format might be much better. > --Gregg
-- Carl Read