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

Home » Public Forums » archive » Re: defining a data structure
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: defining a data structure [message #54463] Thu, 14 June 2007 09:36
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Ingo von Borstel writes:

> Thanks, that's what I've been missing.
> Blind as I am from time to time, I have been unable to deduce this from
> or find it in the manuals.

You're reading the wrong books. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: defining a data structure [message #54464 is a reply to message #54463] Thu, 14 June 2007 09:29 Go to previous message
Ingo von Borstel is currently offline  Ingo von Borstel
Messages: 54
Registered: September 2006
Member
Hi,
>
> my_struct__define.pro
>
> ...and inside that file at least these:
>
> function my_struct::init
>
> self.number = 14
> self.array = indgen(3) * 2
>
> return, 1
> end
>
> pro my_struct__define
> struct_define = { $
> my_struct, $
> number:0, $
> array:intarr(3) $
> }
> end

Thanks, that's what I've been missing.
Blind as I am from time to time, I have been unable to deduce this from
or find it in the manuals.

Best regards,
Ingo


--
Ingo von Borstel <newsgroups@planetmaker.de>
Public Key: http://www.planetmaker.de/ingo.asc

If you need an urgent reply, replace newsgroups by vgap.
Re: defining a data structure [message #54472 is a reply to message #54464] Wed, 13 June 2007 11:39 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Ingo von Borstel writes:

> I'm just starting to dive into IDL objects. As objects are based upon a
> certain struct, I need to define them beforehand. Unfortunately I fail
> to figure out how to put a structure definition into a file such that it
> is automatically found when calling the corresponding object creation
> routine.
>
> Could anyone please point me out how the myobjectstruct__define.pro has
> to look like in order for it being recognized? Just putting in the
> structure's definition doesn't work as well as writing the whole thing
> as a procedure or function.

Huh? Say what!?

Put your structure definition in the LAST module in the
file. Name the module STRUCT__DEFINE and name the file
struct__define.pro and you are finished. (Two underscores
in both the module and filenames.) Then just make the object:

IDL> obj = Obj_New('Struct')

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: defining a data structure [message #54473 is a reply to message #54472] Wed, 13 June 2007 11:33 Go to previous message
jkj is currently offline  jkj
Messages: 48
Registered: April 2007
Member
On Jun 13, 11:58 am, Ingo von Borstel <newsgro...@planetmaker.de>
wrote:
> Hello there,
>
> I'm just starting to dive into IDL objects. As objects are based upon a
> certain struct, I need to define them beforehand. Unfortunately I fail
> to figure out how to put a structure definition into a file such that it
> is automatically found when calling the corresponding object creation
> routine.
>
> Could anyone please point me out how the myobjectstruct__define.pro has
> to look like in order for it being recognized? Just putting in the
> structure's definition doesn't work as well as writing the whole thing
> as a procedure or function.
>
> Best regards,
> Ingo
> --
> Ingo von Borstel <newsgro...@planetmaker.de>
> Public Key:http://www.planetmaker.de/ingo.asc
>
> If you need an urgent reply, replace newsgroups by vgap.


my_struct__define.pro

...and inside that file at least these:

function my_struct::init

self.number = 14
self.array = indgen(3) * 2

return, 1
end

pro my_struct__define
struct_define = { $
my_struct, $
number:0, $
array:intarr(3) $
}
end


...and now I can create an instance of my object:

test = obj_new('my_struct')

Does that help? From there you can make the structure more complicated
and add methods to call, such as "add":

function my_struct::add
return, self.number + self.array
end

...so the call
sum = test->add()
is now valid.

-Kevin
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Dealing with Large data arrays, reducing memory and ASSOC
Next Topic: Re: large widget_trees

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

Current Time: Wed Oct 08 15:16:20 PDT 2025

Total time taken to generate the page: 0.00647 seconds