[comp.sys.mac.hypercard] Variables in a list?

ireland@ac.dal.ca (03/26/91)

Can variables be put into a list and then referred to as items in that
list? I'd like to be able to do the following:

on foobar
  global G1,G2,G3
  put "G1,G2,G3" into myList
  put 77 into item 2 of myList
end foobar

I'd like the value of G2 to be set to 77. Unfortunately, all the above
does is replace G2 with 77 in myList. Being able to do something like
this would be an elegant solution to a scripting problem I have.
Anyone know how to do something like this?

Thanks, Keith Conover
ireland@ac.dal.ca

Susan.A.Tenney@dartmouth.edu (Susan A. Tenney) (03/26/91)

In article <4165@ac.dal.ca>
ireland@ac.dal.ca writes:

> Can variables be put into a list and then referred to as items in that
> list? I'd like to be able to do the following:
> 
> on foobar
>   global G1,G2,G3
>   put "G1,G2,G3" into myList
>   put 77 into item 2 of myList
> end foobar
> 
> I'd like the value of G2 to be set to 77. Unfortunately, all the above
> does is replace G2 with 77 in myList. Being able to do something like
> this would be an elegant solution to a scripting problem I have.
> Anyone know how to do something like this?

Try this:

on foobar
  global G1,G2,G3
  put "G1,G2,G3" into myList
  do "put 77 into" && item 2 of myList
end foobar

The "do" command executes "put 77 into G2".

Susan Tenney
Dartmouth College Computing Services

mrx@dhw68k.cts.com (Mark Murphy) (04/03/91)

In article <4165@ac.dal.ca> ireland@ac.dal.ca writes:
>Can variables be put into a list and then referred to as items in that
>list? I'd like to be able to do the following:
>
>on foobar
>  global G1,G2,G3
>  put "G1,G2,G3" into myList
>  put 77 into item 2 of myList
>end foobar
>
>I'd like the value of G2 to be set to 77. Unfortunately, all the above
>does is replace G2 with 77 in myList. Being able to do something like
>this would be an elegant solution to a scripting problem I have.
>Anyone know how to do something like this?
>

   Try this.....

on foobar
  global G1,G2,G3
  put "G1,G2,G3" into myList
  do "put 77 into" && item 2 of myList
  put 77 into x
  do "put" && quote & x & quote && "into" && item 2 of myList
end foobar

   If you are using HC 2.0, you can do entire scripts with the 'do' command... including 
including conditional statements.


-- 
+-----------------------------------+----------------------------------------+
| Real Life: Mark F. Murphy         | What kinda beer do you like?           |
|   The Net: mrx@dhw68k.cts.com     | Heineken!?  Intercourse that doo-doo!! |
| The Desktop BBS: 714-491-1003     | Pabst Blue Ribbon!!!                   |

Adrian.Amadeo@f13.n396.z1.fidonet.org (Adrian Amadeo) (04/04/91)

You are right:
on foobar
  global G1,G2,G3
  put "G1,G2,G3" into myList
  put 77 into item 2 of myList
end foobar
Once you put an item into quotes ie: "G1,G2,G3"
then it becomes text.  It does not retain it's status as a variable.
---