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

block troubles

 [1/7] from: maarten::koopmans::surfnet::nl at: 9-Mar-2003 22:30


Hi, Say I have a string data: {foreach a b [} Now I want to append this as a block to an empty block: code: copy [] append to-block data error! missing [ at end of script (of course, tehe actual "]" will be appended later) AFAIK this is impossible to do, right? --Maarteb

 [2/7] from: sunandadh:aol at: 9-Mar-2003 17:18


Maarten:
> AFAIK this is impossible to do, right?
I'd never say "impossible" with the number of clever people who contribute here. But it does look rather problematical. to-block requires valid REBOL syntax, so all these will fail too: to-block "6a" ;; invalid integer to-block "7+4" ;; ditto to-block "(" ;; Missing ) at end-of-script to-block "%" ;; Invalid file -- % to-block ":" ;; Invalid word-get -- to-block "[" ;; your case -- Missing ] at end-of-script Sunanda.

 [3/7] from: rgombert:essentiel at: 9-Mar-2003 23:43


ooops, i meant : data: {foreach a b [} code: copy "" append code data append code "this code" append code "]" code to-block code Renaud GOMBERT -------------------------------- www.essentiel.net N SIRET : 418 620 159 N MdA : G316527 NAF/APE : 923A

 [4/7] from: rgombert:essentiel at: 9-Mar-2003 23:41


i suggest you try a different aproach, working on strings and converting to block only once, at the end :
>> data: {foreach a b [} >> code: copy "[" >> append code data >> append code "this code" >> append code "]]" >> code
== "[foreach a b [this code]]"
>> to-block code
== [[foreach a b [this code]]] Renaud GOMBERT -------------------------------- www.essentiel.net N SIRET : 418 620 159 N MdA : G316527 NAF/APE : 923A

 [5/7] from: antonr:iinet:au at: 10-Mar-2003 9:26


Yes, I guess you can't create an improperly matched block to start with. Good, in my opinion. You must finish your block in the string before converting to a block. But why did you need to do this, I wonder? Anton.

 [6/7] from: gscottjones:mchsi at: 9-Mar-2003 16:56


From: "Maarten Koopmans" ...
> Say I have a string data: {foreach a b [} > Now I want to append this as a block to an empty block:
<<quoted lines omitted: 3>>
> (of course, tehe actual "]" will be appended later) > AFAIK this is impossible to do, right?
Hi, Maarten, If you have your heart set on adding these code fragments into a block, one way to do it is: b: [1 2] data1: {foreach a b [} data2: {print a} data3: {]} code: copy [] foreach datum parse data1 none [append code to-word datum] foreach datum parse data2 none [append code to-word datum] foreach datum parse data3 none [append code to-word datum] do load mold code If a string is satisfactory, then: b: [1 2] data1: {foreach a b [} data2: {print a} data3: {]} code: copy "" append code data1 append code data2 append code data3 do code Hope that helps. --Scott Jones

 [7/7] from: maarten:koopmans:surfnet:nl at: 10-Mar-2003 12:21


I am in the process of patching rsp.r and improving the binding (that doesn't work on string!). One way is directly adding to a block!, but converting the compiled page to a block using load/all does the trick as well. --Maarten

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted