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

Home » Public Forums » archive » Re: [Q] readf into an array error
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: [Q] readf into an array error [message #5723 is a reply to message #5714] Sat, 03 February 1996 00:00 Go to previous message
Ken Knighton is currently offline  Ken Knighton
Messages: 44
Registered: May 1995
Member
peter@hpl.hp.com (Peter Webb) wrote:
> Iarla Kilbane-Dawe (iarla@atm.ch.cam.ac.uk) wrote:
>
> : Hello,
>
> : why does IDL give me an error when I try to do?
>
> : a=fltarr(10)
> : i = 0
> : readf,unit,a(i)
>
> This is due to the argument passing mechanism used in IDL. If an array
> is passed to a function, it is passed by reference. If a subarray is
> passed, it is passed by value, and thus cannot be overwritten.

Thanks for the much better description than I gave earlier. One can
also create this problem by using a structure member (a.b) as the
argument. It has been awhile since I thought about it much, so I was a
little bit hazy with my answer.

This little gotcha can really ruin your day if you write or use a
routine that passes data back to the calling routine through arguments
and then use a subarray or a structure member for the argument.
Thinking about this piece of trivia again will probably inoculate me
against this bug for another year.

By the way, I found the documentation for this on page 10-7 of the
user's guide. This documents everything except that structure
members are passed by value. This tidbit is documented on page
7-5 of the user's guide.

Ken Knighton knighton@gav.gat.com knighton@cts.com
General Atomics
San Diego CA
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: Q:Unable to allocate memory?
Next Topic: Output Types

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

Current Time: Wed Oct 08 19:55:29 PDT 2025

Total time taken to generate the page: 0.00428 seconds