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

Home » Public Forums » archive » Accessing class structure fields outside the class
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
Accessing class structure fields outside the class [message #90973] Tue, 19 May 2015 13:12 Go to next message
evan.jones@richmond.e is currently offline  evan.jones@richmond.e
Messages: 1
Registered: May 2015
Junior Member
Hello everyone. I would like to access field values in class structures outside their class.

For example:

Pro class1__define
struct = {class1, value:5, pointer:new_ptr(3)}
end

Pro main
a = {class1}
print, a.value, *a.pointer
end

This approach 'zeros' the values inside class1's structure and turns any pointers into a null pointer. Is there a way to access the field values in class1's struct outside the class? Among other reasons, I want to accomplish this without having class1's structure be defined in main so that other methods, functions, and procedures can operate on the field values as they change during a calculation
Re: Accessing class structure fields outside the class [message #90974 is a reply to message #90973] Tue, 19 May 2015 13:28 Go to previous messageGo to next message
Russell[1] is currently offline  Russell[1]
Messages: 101
Registered: August 2011
Senior Member
You're making a few mistakes here.

The class prototype (your class1__define), only defines the datatypes of the class fields. So the fact that you use "value:5" is irrelevant, since this procedure simply defines class1 as a named structure that will contain field named "value" which is an integer. Similarly, you have a field named "pointer" which is a pointer data type.

You will need to explicitly initialize the data. In your example this would be:

pro class1__define
foo = {CLASS1, value:0, pointer: ptr_new()}
end

pro main
a={class1,5,ptr_new(4.)}

print, a.value, *a.pointer
end

Hope this helps.

Russell


On Tuesday, May 19, 2015 at 4:12:28 PM UTC-4, evan....@richmond.edu wrote:
> Hello everyone. I would like to access field values in class structures outside their class.
>
> For example:
>
> Pro class1__define
> struct = {class1, value:5, pointer:new_ptr(3)}
> end
>
> Pro main
> a = {class1}
> print, a.value, *a.pointer
> end
>
> This approach 'zeros' the values inside class1's structure and turns any pointers into a null pointer. Is there a way to access the field values in class1's struct outside the class? Among other reasons, I want to accomplish this without having class1's structure be defined in main so that other methods, functions, and procedures can operate on the field values as they change during a calculation
Re: Accessing class structure fields outside the class [message #90975 is a reply to message #90973] Tue, 19 May 2015 13:30 Go to previous message
Matthew Argall is currently offline  Matthew Argall
Messages: 286
Registered: October 2011
Senior Member
On Tuesday, May 19, 2015 at 2:12:28 PM UTC-6, evan....@richmond.edu wrote:
> Hello everyone. I would like to access field values in class structures outside their class.
>
> For example:
>
> Pro class1__define
> struct = {class1, value:5, pointer:new_ptr(3)}
> end
>
> Pro main
> a = {class1}
> print, a.value, *a.pointer
> end
>
> This approach 'zeros' the values inside class1's structure and turns any pointers into a null pointer. Is there a way to access the field values in class1's struct outside the class? Among other reasons, I want to accomplish this without having class1's structure be defined in main so that other methods, functions, and procedures can operate on the field values as they change during a calculation

You can have your class inherit IDL_Object:

http://exelisvis.com/docs/IDL_Object.html

See the "IDL_Object and Property Access" section on this page:

http://exelisvis.com/docs/WhatsNew_in_8_0.html

Also, look at "Automatic Class Structure Definition" on this page:

http://exelisvis.com/docs/creating_an_object_class_1.html


You are nearly there.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: calling functions directily
Next Topic: Creaty dummy.jpeg with Linux command

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

Current Time: Wed Oct 08 13:32:12 PDT 2025

Total time taken to generate the page: 0.00681 seconds