Passing parameters by reference

Pete pete at mollysrevenge.com
Sat Mar 10 15:23:58 EST 2012


That would work but the complication is that the function is already
returning true or false to indicate whether it changed the input or not so
I can do something like:

if modified(tvar) then
   --do something
else
  --do something else
end if

If I change it to return the result of it's operation on the input, I'd
have to do something like

put modified(tvar) into tTemp
if ttemp<>tvar then
  --do something
else
  --do something else
end if

That works just fine but just seems more elegant to be able to do it the
first way, especially since most of the time I'm calling the function with
a simple variable as the input, not an array element, and the first way of
doing it works just fine.

Anyway, there's multiple ways to work around the problem until LC is fixed
to allow array elements to be passed by reference (hopefully!)

Thanks,
Pete

On Sat, Mar 10, 2012 at 11:34 AM, Dar Scott <dsc at swcp.com> wrote:

>
> On Mar 10, 2012, at 11:21 AM, Pete wrote:
> > I may as well just change the function to return the
> > result of its code and pass the parameter by value instead of reference.
>
> Hmm.  Like this?
>
> put modified(a[s]) into a[s]
>
> This might be the best for now.
>
> Dar
>
> ---------------------------
> Dar Scott
> dba
> Dar Scott Consulting
> 8637 Horacio Place NE
> Albuquerque, NM 87111
>
> Lab, home, office phone: +1 505 299 9497
> For Skype and fax, please contact.
> dsc at swcp.com
>
> Computer Programming and tinkering,
> often making LiveCode libraries and
> externals, sometimes writing associated
> microcontroller firmware.
> ---------------------------
>
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>


-- 
Pete
Molly's Revenge <http://www.mollysrevenge.com>



More information about the Use-livecode mailing list