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

Home » Public Forums » archive » Re: Returning ARRAYs from functions?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Returning ARRAYs from functions? [message #29783] Wed, 13 March 2002 16:15
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
"R.A" <roa@aber.ac.uk> writes:

> I have been rewriting some software in IDL5.4 passed onto me
> by a former colleague.
> Essentially the function is required to correct an array of values
> by applying a polynomial and then return the corrected array.
>
> I have noted this doesnt work as I have stated although I
> had the idea IDL could pass any dimension array to a
> function and return the array from the function.
>
> What seems to have been done is to create a structure from
> the array passed and return the structure.
>
> Is what I have said correct? ... that you need to pass data arrays
> from IDL functions as data structures as arrays cannot be
> passed??

Yes, arrays can be passed to and from IDL functions. You said it
"doesn't work" but that is not enough to really make a good diagnosis.

In addition to the other suggestions so far, I would offer another
possibility. There are some cases where an array can get truncated,
especially when multiplying quantities of different dimensions (as
might be the case with a polynomial multiplication). My suggestion is
to trace through your procedure and make sure the dimensions remain
what you think they should be.

Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: Returning ARRAYs from functions? [message #29785 is a reply to message #29783] Wed, 13 March 2002 14:31 Go to previous message
Robert Stockwell is currently offline  Robert Stockwell
Messages: 74
Registered: October 2001
Member
You can return arrays from an IDL function.
-bob


function passarray,length

a = findgen(length > 1)
return,a

end



R.A wrote:

> I have been rewriting some software in IDL5.4 passed onto me
> by a former colleague.
> Essentially the function is required to correct an array of values
> by applying a polynomial and then return the corrected array.
>
> I have noted this doesnt work as I have stated although I
> had the idea IDL could pass any dimension array to a
> function and return the array from the function.
>
> What seems to have been done is to create a structure from
> the array passed and return the structure.
>
> Is what I have said correct? ... that you need to pass data arrays
> from IDL functions as data structures as arrays cannot be
> passed??
>
> Comments please.
>
>
>
Re: Returning ARRAYs from functions? [message #29789 is a reply to message #29785] Wed, 13 March 2002 12:19 Go to previous message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
"R.A" <roa@aber.ac.uk> wrote in message news:1016045211.381484@dyfi...
>
> Is what I have said correct? ... that you need to pass data arrays
> from IDL functions as data structures as arrays cannot be passed??

No. Arrays definitely can be passed to & from IDL functions &
procedures.

Are you passing the data via a function return value, named parameters
or keyword parameters? There are a few subtleties to the way IDL
passes parameters that could be ocnfusing you. Please tell us more
about what you are doing.

--
Mark Hadfield
m.hadfield@niwa.co.nz Ka puwaha et tai nei
http://katipo.niwa.co.nz/~hadfield Hoea tatou
National Institute for Water and Atmospheric Research (NIWA)
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: fun typos in IDL
Next Topic: Re: AVI reader/writer dll available

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

Current Time: Wed Oct 08 19:04:48 PDT 2025

Total time taken to generate the page: 0.00668 seconds