comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Multiple values from a function?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Multiple values from a function? [message #20570 is a reply to message #20562] Tue, 04 July 2000 00:00 Go to previous messageGo to previous message
meron is currently offline  meron
Messages: 51
Registered: July 1995
Member
In article <3961EFA8.49657FB6@mathstat.dal.ca>, Simon de Vet <simon@mathstat.dal.ca> writes:
> I have a function that does a whole lot (it started out as an
> independent program). It works very well when returning one of it's
> calculated arrays.
>
> It also produces a number of other arrays which I'd like to have access
> to. Unfortunately, I have discovered that a function can only return
> one value.
>
> How can I get the other arrays out of it? The code is intertwined, so it
> would be hard to break into 2 or 3 independent functions.
>
You can easily return them using keyword parameters. Lets say that
your function FUN calculates 3 arrays (internally known as XARR, YARR
and ZARR) and returns XARR. Then, modify the definition of the
function to something like

Fuction FUN, ... ..., second = yarr, third = zarr

....

return, xarr
end

Now, if you'll issue a call like

u = Fun( .... ,second = v, third = w)

then after the call U will contain the calculated XARR, V will contain
YARR, w will contain ZARR. This can be extended indefinitely. Note
that neither U not V or W need to be defined at all, prior to the
call.

Mati Meron | "When you argue with a fool,
meron@cars.uchicago.edu | chances are he is doing just the same"
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Vertices and Polygons
Next Topic: Impressions on IDL for Macintosh?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sun Oct 12 14:53:23 PDT 2025

Total time taken to generate the page: 0.96733 seconds