[REBOL] Re: "picking' from a block.....
From: AJMartin:orcon at: 23-Jul-2004 16:00
John wrote:
> The 'add-number' function below calls the 'build-a-blk' function also
below.
> The 'remove' fails as shown....after the printing of 'add-blk' has
> shown its content as: "66", "66", "66", "66", "66", "66", ""
>
> I thought blocks were series.....what is more common than the endless
> references to 'picking' block values in RTOC (Rebol, The Official Guide) ?
Yes, block! values are series.
****************************************************************************
**************
> Error from invoking the script:
>
> "66","66","66","66","66","66",""
> ** Script Error: remove expected series argument of type: series port
bitset none
> ** Where: add-number
> ** Near: remove pick add-blk 7
>
****************************************************************************
****************
> build-a-blk: func [ /local blk][
> blk: copy ""
Please note that at this point, the value referred to by the 'blk is a
string! value.
> append blk remold to-string num1/text
> append blk ","
> append blk remold to-string num2/text
> append blk ","
> append blk remold to-string num3/text
> append blk ","
> append blk remold to-string num4/text
> append blk ","
> append blk remold to-string num5/text
> append blk ","
> append blk remold to-string num6/text
> append blk ","
> append blk remold to-string num7/text
> return blk
'build-a-blk returns the string from above.
> ]
>
> add-number: func [ /local add-blk block!][
> add-blk: build-a-blk
> print [add-blk]
> remove pick add-blk 7
The 'pick returns the seventh character of the string returned by
'build-a-blk which is not a series, so 'remove returns an error.
> db-insert lottoReb ["5" "Powerball" reduce add-blk 20-JUL-2004]
> return
> ]
Note that functions don't need an explicit 'return word.
The function abbreviations 'has and 'does will be of interest to you.
I'm not sure what you're trying to create; could we have an example please?
That way, I'm sure we could suggest far better alternatives.
--
Andrew J Martin
ICQ: 26227169
http://www.rebol.it/Valley/
http://valley.orcon.net.nz/
http://valley.150m.com/