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

String to Object

 [1/3] from: kpeters:otaksoft at: 27-May-2009 17:26


Hi all ~ Given a block of strings as in names: [ =93Joe=94 =93Mary=94 =93Wilbur=94 ] and an object template template: make object! [ count: 0 units: [] ] How do I create an object for each of the names in the names block so that I may do probe Joe/count or probe Mary/units TIA, Kai

 [2/3] from: gerardcote:gm:ail at: 27-May-2009 21:27


Hi Kai, 2009/5/27 Kai Peters <kpeters-otaksoft.com>
>Given a block of strings as in >names: [ =93Joe=94 =93Mary=94 =93Wilbur=94 ] >and an object template >template: make object! [ count: 0 units: [] ] >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: count integer! 0 units block! length: 0
>> help Mary
MARY is an object of value: count integer! 0 units block! length: 0
>> Wilbur/count
== 0 -- Gérard Côté Québec, Canada

 [3/3] 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>
<<quoted lines omitted: 22>>
> 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

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