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

Home » Public Forums » archive » own function with equation
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
own function with equation [message #8856] Tue, 06 May 1997 00:00
R. Bauer is currently offline  R. Bauer
Messages: 137
Registered: November 1996
Senior Member
Hi,

How did I have to write a function which will allow input like

a=where2(b gt 10)?


--
R.Bauer

Institut fuer Stratosphaerische Chemie (ICG-1)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
Re: own function with equation [message #8859 is a reply to message #8856] Mon, 05 May 1997 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
R. Bauer writes:

> in addition to the first question I did:
>
> FUNCTION where2,arr,b,count
> return,arr
> end
>
> If i define this function and i call it like
> a=indgen(10)
> print,where2(a gt 4)
>
> the result is 0 0 0 0 0 1 1 1 1 1
>
> what is wrong?

My news server has been screwy all weekend, so I didn't
see the first question. But there is *nothing* wrong here.

Do this:

a = Indgen(10)
Print, (a gt 4)

You get the result exactly as you do above:
0 0 0 0 0 1 1 1 1 1

This is, in fact, *exactly* what you put into the
WHERE2 function above as its argument (called "arr"
inside the program). In this case, you passed the
argument in by *value*. Perhaps you expected it
to be passed in by reference. All expressions (which
this is), subscripted variables, structure de-references,
etc are passed by value. Only variables are passed
by reference.

This result is exactly what I would expect.

Cheers!

David

----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
Customizable IDL Programming Courses
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: own function with equation
Next Topic: Re: widget_droplist keyword problem

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

Current Time: Thu Oct 09 15:01:27 PDT 2025

Total time taken to generate the page: 1.59840 seconds