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

Block as parameter

 [1/5] from: info:id-net:ch at: 17-Aug-2002 10:03


Hello RebList ! I often pass as parameter a block to a function. The block is often the result of a read/lines function. The problem is that, when I pass this block as parameter, it seems that block is changed : Below, a: read/lines %theTXT.txt length? a ; --> 12 ; because of 12 lines but when i pass 'a to a function the result is : make-this: func [the-block] [ print length? the-block; ----> 120 ; because for example, my txt has a 10 column structure ] make-this a How could I keep the block intact, without any transformation ?? Phil

 [2/5] from: al:bri:xtra at: 17-Aug-2002 21:30


Phil wrote:
> The problem is that, when I pass this block as parameter, it seems that
block is changed :
>> cd %/c/Temp/
== %/c/Temp/
>> write %theTXT.txt {A test file
{ with at least twelve lines. { This is the third line... { and this is the fourth line. { Fifth line. { Sixth line. { Seventh line. { Eighth line. { Nine lines to here. { Tenth line. { Another makes eleven. { And the final makes 12. { }
>> a: read/lines %theTXT.txt
== ["A test file" "with at least twelve lines." "This is the third line. .." "and this is the fourth line." "Fifth line." "Sixth lin...
>> length? x
** Script Error: x has no value ** Near: length? x
>> length? a
== 12
>> make-this: func [the-block] [
[ print length? the-block [ ]
>> make-this a
12 Seems to be unchanged according to me. Perhaps there's a bug in other parts of your script? Or you could have altered some words used by Rebol. Andrew Martin ICQ: 26227169 http://valley.150m.com/

 [3/5] from: carl:cybercraft at: 17-Aug-2002 23:57


On 17-Aug-02, Philippe Oehler wrote:
> Hello RebList ! > I often pass as parameter a block to a function. The block is often
<<quoted lines omitted: 10>>
> make-this a > How could I keep the block intact, without any transformation ??
Like Andrew, I couldn't duplicate your problem. I wondered if it had something to do with tabs in your text to create your "10 column structure", but tabs made no difference. A block, passed to a function, should still be the same block - no changes to it should occur. So, what do you mean by a 10 column structure? -- Carl Read

 [4/5] from: joel::neely::fedex::com at: 17-Aug-2002 8:52


Hi, Phil, You've got something else happening to your data... Philippe Oehler wrote:
> Hello RebList ! > I often pass as parameter a block to a function. The block is
<<quoted lines omitted: 12>>
> make-this a > How could I keep the block intact, without any transformation ??
As you can see below, I can't reproduce your described problem:
>> someblock: [
[ "0123456789" [ "0123456789" [ "0123456789" [ "0123456789" [ "0123456789" [ "0123456789" [ "0123456789" [ "0123456789" [ "0123456789" [ "0123456789" [ "0123456789" [ "0123456789" [ ] == [ "0123456789" "0123456789" "0123456789" "0123456789" "0123456789" "0123456789" "0123456789" ... (twelve entries of ten characters each)
>> length? someblock
== 12
>> make-this: func [the-block] [
[ print length? the-block [ ]
>> make-this someblock
12 Both give the correct length of the block. OTOH, remember that blocks are mutable, so if we pass a block to a function that modifies its content/structure, then that change will persist. Are you sure there's nothing like that happening in your original code? -jn- -- ; Joel Neely joeldotneelyatfedexdotcom REBOL [] do [ do func [s] [ foreach [a b] s [prin b] ] sort/skip do function [s] [t] [ t: "" foreach [a b] s [repend t [b a]] t ] { | e s m!zauafBpcvekexEohthjJakwLrngohOqrlryRnsctdtiub} 2 ]

 [5/5] from: info:id-net:ch at: 17-Aug-2002 16:25


Yes, friends.. something happened to my database.. it is parsed .. and so the number of elements is multiplied by 10, because of it..

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