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

Home » Public Forums » archive » Re: Object as a member to object/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
Re: Object as a member to object/class [message #58696] Tue, 12 February 2008 16:50 Go to next message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
A few more comments...

On Feb 12, 1:45 pm, Sven Utcke <utcke+n...@informatik.uni-hamburg.de>
wrote:
>   PRO MODBUS__DEFINE
>       struct = { MODBUS, Host:"hasgkssccdkal.desy.de", Port:502, tid:0L }
>   END

Be careful here. Those values "hasgkssccdkal.desy.de", 502, and 0L are
only used for their type. The actual values are thrown away. Normally,
I do something like:

struct = { MODBUS, host: '', port: 0, tid: 0L }

so I don't fool myself.

I second that you should read David's article (N_ELEMENTS is probably
what you want to use in GKSSBC::INIT).

Mike
--
www.michaelgalloy.com
Tech-X Corporation
Software Developer II
Re: Object as a member to object/class [message #58698 is a reply to message #58696] Tue, 12 February 2008 14:10 Go to previous messageGo to next message
ben.bighair is currently offline  ben.bighair
Messages: 221
Registered: April 2007
Senior Member
On Feb 12, 3:45 pm, Sven Utcke <utcke+n...@informatik.uni-hamburg.de>
wrote:
> Hi,
>
> I'm plainly too stupid for the following: I would like to have an
> object as a member to a second class. I.e. I have something like
> this:
>
> PRO MODBUS__DEFINE
> struct = { MODBUS, Host:"hasgkssccdkal.desy.de", Port:502, tid:0L }
> END
>
> and, later on,
>
> PRO GKSSBC__DEFINE
> struct = { GKSSBC, Con:Obj_New(), addr:'4020'XL, Factor:1.0, Steps:200, Micro:6 }
> END
>
> Now, I would _like_ to do something like
>
> FUNCTION GKSSBC::INIT, addr = addr, factor = factor, con = con
> IF KEYWORD_SET(addr) THEN self.Addr = addr ELSE self.Addr = '4020'XL
> IF KEYWORD_SET(factor) THEN self.Factor = factor ELSE self.Factor = 1.0
> IF KEYWORD_SET(con) THEN self.Con = con ELSE self.Con = obj_new("modbus")
> return, 1
> END
>
> But even just doing
>
> FUNCTION GKSSBC::INIT
> self.Con = obj_new("modbus")
> return, 1
> END
>
> does't wor at all in IDL 6.4 (it results in something like:
>
> % Object reference expression not allowed in this context: <OBJREF
> (<ObjHeapVar38(MODBUS)>)>.
> % Execution halted at: GKSSBC::INIT 13
> /afs/desy.de/user/u/utcke/src/Modbus/gkss9100C.pro
> % OBJ_NEW
> % $MAIN$
>
> So how does this _really_ work?

Hi,

No such thing as too stupid. Learning curves can be twisted, that's
all. My first thought is that MODBUS does not have an MODBUS::INIT
method since you don't show it. Can you successfully instantiate a
MODBUS object on its own? Like...

IDL> obj = OBJ_NEW("MODBUS")

On a different note, you might find it fruitful to look at David
Fanning's excellent description of when to use KEYWORD_SET vs.
N_ELEMENTS. http://www.dfanning.com/tips/keyword_check.html

Cheers,
Ben
Re: Object as a member to object/class [message #58699 is a reply to message #58698] Tue, 12 February 2008 13:57 Go to previous messageGo to next message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On Feb 12, 1:45 pm, Sven Utcke <utcke+n...@informatik.uni-hamburg.de>
wrote:
> I'm plainly too stupid for the following: I would like to have an
> object as a member to a second class.  I.e. I have something like
> this:
>
>   PRO MODBUS__DEFINE
>       struct = { MODBUS, Host:"hasgkssccdkal.desy.de", Port:502, tid:0L }
>   END
>
> and, later on,
>
>   PRO GKSSBC__DEFINE
>       struct =  { GKSSBC, Con:Obj_New(),  addr:'4020'XL, Factor:1.0, Steps:200, Micro:6 }
>   END
>
> Now, I would _like_ to do something like
>
>   FUNCTION GKSSBC::INIT,  addr = addr, factor = factor,  con = con
>       IF KEYWORD_SET(addr)   THEN self.Addr   = addr   ELSE self.Addr   = '4020'XL
>       IF KEYWORD_SET(factor) THEN self.Factor = factor ELSE self.Factor = 1.0
>       IF KEYWORD_SET(con)    THEN self.Con    = con    ELSE self.Con    = obj_new("modbus")
>       return,  1
>   END
>
> But even just doing
>
>   FUNCTION GKSSBC::INIT
>       self.Con = obj_new("modbus")
>       return,  1
>   END
>
> does't wor at all in IDL 6.4 (it results in something like:
>
>   % Object reference expression not allowed in this context: <OBJREF  
>     (<ObjHeapVar38(MODBUS)>)>.
>   % Execution halted at: GKSSBC::INIT       13
>     /afs/desy.de/user/u/utcke/src/Modbus/gkss9100C.pro
>   %                      OBJ_NEW        
>   %                      $MAIN$          
>
> So how does this _really_ work?
>
> Any help appreciated!

Your code works for me. The only thing I can think of is that you
might have changed the definition of self.con without .reset-ing or
exiting IDL?

Mike
--
www.michaelgalloy.com
Tech-X Corporation
Software Developer II
Re: Object as a member to object/class [message #58765 is a reply to message #58699] Thu, 14 February 2008 06:13 Go to previous message
Sven Utcke is currently offline  Sven Utcke
Messages: 10
Registered: October 2007
Junior Member
"mgalloy@gmail.com" <mgalloy@gmail.com> writes:

> On Feb 12, 1:45�pm, Sven Utcke <utcke+n...@informatik.uni-hamburg.de>
> wrote:
>> I'm plainly too stupid for the following: I would like to have an
>> object as a member to a second class. �I.e. I have something like
>> this:

> Your code works for me.

And so it does indeed. Today.

> The only thing I can think of is that you
> might have changed the definition of self.con without .reset-ing or
> exiting IDL?

Sounds very likely indeed.

Thank you very much (also the other two posters) for your help. It
now works exactly as intended (well, the cases I have tested so far
:-)...

Sven
--
___ _ _____ ___ Dr.-Ing. Sven Utcke ___ ___ _____ __
/ __| |/ / __| __| phone: +49 40 8998-5317 | \| __/ __\ \ / /
| (_ | ' <\__ \__ \ fax : +49 40 8994-5317 (NEW) | |) | _|\__ \\ V /
\___|_|\_\___|___/ http://www.desy.de/~utcke (to come)|___/|___|___/ |_|
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: IDLVM arguments
Next Topic: Using callable IDL from a Qt application

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

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

Total time taken to generate the page: 0.00619 seconds