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

Home » Public Forums » archive » Re: Dynamically sized arrays
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: Dynamically sized arrays [message #8889] Wed, 30 April 1997 00:00
David Foster is currently offline  David Foster
Messages: 341
Registered: January 1996
Senior Member
Michael Wu wrote:
>
> Is there a way to dynamically size arrays? I am
> writing a program to read data from files of unknown
> quantity of data. Or is the only way to use handles?
> I am at a loss to program handles.
>

First, I would pass along a gently RTFM, as your question could
be answered pretty easily with a little perusing of the manuals.

To dynamically create arrays, just use the array creation routines
and use variables to specify how big you want them to be, eg:

array = intarr(xdim, ydim)

(see also bytarr, lonarr, fltarr, strarr, dblarr, complexarr). Or
you can use the even more convenient MAKE_ARRAY routine.

As far as handles go, it's really not as intimidating as it sounds.
Here's an example:

handle = handle_create() ; Create handle
a = dist(100,100) ; Create some data
handle_value, handle, a, /set, /no_copy ; Give data to handle

...

handle_value, handle, new_a ; Later, get data from handle

...

handle_free, handle ; Be sure to free!

You can keep handles in common-blocks or, even better, put them in
a structure and make that structure the UVALUE of the top-level-base
(or first child) of your widget. See the User's Guide section on
widget programming for an example of saving the "state information"
this way, and using it in your event handler.

Good luck! A good motto is "RTFM first, then post..."

Dave
--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
David S. Foster Univ. of California, San Diego
Programmer/Analyst Brain Image Analysis Laboratory
foster@bial1.ucsd.edu Department of Psychiatry
(619) 622-5892 8950 Via La Jolla Drive, Suite 2200
La Jolla, CA 92037
[ UCSD Mail Code 0949 ]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: All writers seeking publication
Next Topic: Error in concatenating structure arrays

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

Current Time: Sun Nov 30 09:38:08 PST 2025

Total time taken to generate the page: 1.36353 seconds