[REBOL] Re: String to Object
From: izkata:gma:il at: 27-May-2009 23:19
In that case, all 3 names point at the same object:
>> names: [ "Joe" "Mary" "Wilbur" ]
== ["Joe" "Mary" "Wilbur"]
>> template: make object! [ count: 0 units: [] ]
>> foreach name names [set to-word name :template]
>> ? Joe
JOE is an object of value:
count integer! 0
units block! length: 0
>> Joe/count: 4
== 4
>> Mary/count
== 4
What you want is this:
foreach name names [set to-word name make template []]
Keep in mind that changing count above like I did also changed the
object that template pointed to, so it has to be remade/reset before
doing the new foreach loop.
On Wed, May 27, 2009 at 8:27 PM, G=C3=A9rard C=C3=B4t=C3=A9 <gerardcote-gmail.com> wrote:
> Hi Kai,
>
> 2009/5/27 Kai Peters <kpeters-otaksoft.com>
>
>>Given a block of strings as in
>
>>names: =C2=A0[ =93Joe=94 =93Mary=94 =93Wilbur=94 ]
>
>>and an object template
>
>>template: make object! [ count: 0 =C2=A0units: [] ]
>
>>How do I create an object for each of the names in
>>the names block so that I may do
>
> I tried the following and it seems that it worked :
>
>>> foreach name names [set to-word name :template]
>
>>> help joe
> JOE is an object of value:
> =C2=A0 count =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 integer! =C2=A00
> =C2=A0 units =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 block! =C2=A0 =C2=A0length: 0
>
>>> help Mary
> MARY is an object of value:
> =C2=A0 count =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 integer! =C2=A00
> =C2=A0 units =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 block! =C2=A0 =C2=A0length: 0
>
>>> Wilbur/count
> == 0
>
> --
> G=C3=A9rard C=C3=B4t=C3=A9
> Qu=C3=A9bec, Canada
>
> --
> To unsubscribe from the list, just send an email to
> lists at rebol.com with unsubscribe as the subject.
>
--
=E5=A5=8F=E3=81=A7=E3=81=A6=E5=A4=A2