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

Home » Public Forums » archive » Re: object creation question
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: object creation question [message #11531] Thu, 23 April 1998 00:00 Go to previous message
Evilio del Rio is currently offline  Evilio del Rio
Messages: 17
Registered: December 1997
Junior Member
On Mon, 20 Apr 1998, Louis J. Wicker wrote:

> I am trying to use objects to help develop a 2D plotting package for my
> cloud model data. I have run into a conceptual snag, and think that I am
> missing something obvious. Suppose I want to create an object which
> stores, amoung other things, a 2d array of data (like for imaging or
> contouring, etc). So I create the object using:
>
> --
> data2d = obj_new('scalar2d')
> --
>
> Then I define a structure definition as:
>
> --
> Pro scalar2d__define
>
> struct = {scalar2d, sdata: fltarr(nx,ny)}
>
> End
> --
>
> and then an init method:
>
> --
> Pro scalar2d::init
>
> array = fltarr(20,30)
>
> self.sdata = array
>
> End
> --

Hi Louis,

You need to use pointers. That's the not so obvious bit you are missing.
Look the documentation for the procedures, PTR_NEW(), PTR_FREE,
PTR_VALID(), etc. Here's a bit of code that can do what you
want (more or less...):

FUNCTION scalar2d::init,DATA=data ; Init method must be a function.

if (N_Elements(data) GT 1) then begin
; Put stuff to chek if input data is correct...
endif else return,0

self.sdata = PTR_NEW(data)
return,1

End



Pro scalar2d::cleanup

PTR_FREE,self.sdata ; Clean up allocated memory.

end



Pro scalar2d::plot

plot, *self.sdata

end


Pro scalar2d__define

struct = {scalar2d, sdata: PTR_NEW()}

End


---

data2d = obj_new('scalar2d',DATA=myData)

---


Hth.
Cheers,

____________________________________________________________ ________
Evilio Jose del Rio Silvan Institut de Ciencies del Mar
E-mail: edelrio@icm.csic.es URL: http://www.ieec.fcr.es/~evilio/
"Anywhere you choose,/ Anyway, you're gonna lose"- Mike Oldfield
[Message index]
 
Read Message
Read Message
Previous Topic: Re: gzipped files
Next Topic: Re: idl process id

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

Current Time: Fri Oct 10 09:40:34 PDT 2025

Total time taken to generate the page: 0.63938 seconds