assign by reference (arrays)?

Tom Emerson osnut at
Fri Mar 22 05:21:00 EST 2002

> -----Original Message-----
> From: Rob Cozens
> [Ben wrote]
> >My first attempt was the equivalent of
> >      [...]
> >         switch msgList
> >         case "use"
> >             put aUseInfo into aInfo
> >             break
> >         case "improve"
> >             put aImproveInfo into aInfo
> >             break
> >         end switch
> >         get aInfo[rID]
> >         if it = empty then
> >             put 1 && mID into aInfo[rID]
> >But that doesn't work, because 'aInfo' is each time a fresh
> copy of either
> >the 'aUseInfo' array, or the 'aImproveInfo' array.

I think I understand what Ben is after -- to [vaguely] borrow terminology
from other languages, what it appears he wants to do is:

   case "use"
     put ADDRESS_OF(aUseInfo) into aInfoPointer
   end switch
   add 1 to TARGET_OF(aInfoPointer)[rID]

[note: I'm COMPLETELY new to this "language" -- while I have a number of
other languages under my belt, I'm not entirely sure I want to tackle one
where the global variable "it" changes context from line to line... ;) ]
Does this "language" support pointer variables [and all the nastiness
associated with them] or is this a dead avenue?

A bit of a SWAG here, but from another post, it appears that by using the
"do" command it's possible to "dereference" a variable so long as you know
it's name.  If I picked up on the proper usage, it should be something like

   case "use"
     put "aUseInfo" into aInfo
   case "improve"
     put "aImproveInfo" into aInfo
   end switch
   put ("add 1 to " & aInfo & "[rID]") into aStatement
   do (it)

[ok, that last line is a cheesy shot at this whole "it" variable business ;)
It should either be "do (aStatement)", or simply replace the last "put" with
"do" and take out the "into aStatement" part -- i.e., do the whole thing

> Try this, Ben,
[paraphrased -- please let me know if I'm way off base here...]
>          switch msgList
>          case "use"
>              put -- (i.e., completely copy)
                  aUseInfo into -- a temporary variable called
>              put true into fromUse
>          end switch
           -- manipulate the copied array
>          get aInfo[msgReplyID]
           -- then copy it back to the original
>          if fromUse then put aInfo into aUseInfo else put aInfo into
>             aImproveInfo

However it appears even you have doubts about this as you brought up a few
cases in another post where it sounds like this is a less-than-optimal
solution [not even taking into consideration the fact that dereferencing a
pointer takes the same number of cycles & memory space regardless of the
array being 10 bytes or 10 megabytes in size, OTOH, "copies" of entire

More information about the use-livecode mailing list