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

Home » Public Forums » archive » Re: Passing more than one variable out of 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: Passing more than one variable out of a function. [message #65846 is a reply to message #65828] Wed, 25 March 2009 01:14 Go to previous messageGo to previous message
philipelson is currently offline  philipelson
Messages: 9
Registered: March 2009
Junior Member
On 25 Mar, 04:31, Ben <Benjamin.R.Ev...@gmail.com> wrote:
> The IDL intrinsic function WHERE can pass more than one variable out
> to the calling program.
>
> For example:
>
>> array=[0,2,4,6,8,10]
>> arr_subscripts = WHERE(array GT 5, count)
>> print, arr_subscripts
>
> 3,4,5
>
>> print, count
>
> 3
>
> The question is how can I write a user defined function which can pass
> more than one variable out to the calling program. Just like the WHERE
> function?
>
> I know that I could just use a procedure to do this. But I am just
> curious.

Hi Ben,

WHERE is simply passing an array back to you, you can do the same with
the example code below:

FUNCTION test, count=count
IF ARG_PRESENT(count) THEN count=3
RETURN, [3,4,5]
END

print, test(count=mycountvar)
print, mycountvar


The important thing to notice is that RETURN can accept an array as a
parameter.

Hope this helps.

Cheers,

Philip
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Symsize doesn't seem to work?
Next Topic: Re: Help With Finding Local Maxima of an Image (locmax)

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

Current Time: Wed Oct 08 18:03:35 PDT 2025

Total time taken to generate the page: 0.00377 seconds