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

Home » Public Forums » archive » Pointers and Objects
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: Pointers and Objects [message #35768 is a reply to message #35571] Tue, 08 July 2003 06:47 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Johan Marais writes:

> I want to create an object with a pointer as one data member. When the
> object initialize it zero all the data members and the pointer becomes a
> NULL pointer. To me it seems that it is unusable now because you cannot
> change a NULL pointer. Anybody knows what can be done?

Well, you certainly can change a NULL pointer to *something*
or what would be the point? At the time you want to fill it
up, you could have code like this:

IF Ptr_Valid(self.ptr) THEN *self.ptr = mything ELSE $
self.ptr = Ptr_New(mything)

Or, if you want to initialize a pointer in the INIT method
to something that can always be dereferenced, you could
allocate memory, but not store anything. This is
essentially the same as storing an undefined variable in
the pointer:

self.ptr = Ptr_New(/Allocate_Heap)

Then, later:

*self.ptr = mything

Cheers,

David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Histogram looks like spiky bars
Next Topic: Re: using ion scripts for local server -apache

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

Current Time: Fri Oct 17 21:31:06 PDT 2025

Total time taken to generate the page: 1.35911 seconds