|
Re: own function with equation [message #8859 is a reply to message #8856] |
Mon, 05 May 1997 00:00  |
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
|
|
|