assign by reference (arrays)?

Ben Rubinstein benr_mc at cogapp.com
Wed Mar 20 07:59:01 EST 2002


Is there any way to assign by reference?

I have half a dozen arrays in half a dozen variables.  As I'm in a loop
processing some incoming data, in response to the data I pick one of these
arrays that I want to work on (including modifying some data in the array).
If the code that worked on the array was in a sub-procedure, I could do
something like this

    switch (...)
    case a:
        dostuffto(arrayA, ...)
        break
    case b:
        dostuffto(arrayB, ...)
        break
    end switch

.... provided that 'dostuffto' was declared to take the first parameter by
reference.  But what if want to do the stuff inline?  I tried this:

    switch (...)
    case a:
        get arrayA
        break
    case b:
        get arrayB
        break
    end switch
    ...do stuff to array in 'it'...

But this doesn't work, because the statement "get arrayA" puts a _copy_ of
the array in the variable "arrayA" into the variable "it".  Fine if you only
wanted to do stuff that involves reading data out of the array; no good if
you also want to write to it.

So is there a way to say "put x into y" that means "make 'y' point to the
same object as 'x'"???

 
  Ben Rubinstein               |  Email: benr_mc at cogapp.com
  Cognitive Applications Ltd   |  Phone: +44 (0)1273-821600
  http://www.cogapp.com        |  Fax  : +44 (0)1273-728866





More information about the use-livecode mailing list