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

Home » Public Forums » archive » objects and call external
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
objects and call external [message #29273] Tue, 12 February 2002 12:15 Go to next message
Gert is currently offline  Gert
Messages: 11
Registered: December 2001
Junior Member
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META content="MSHTML 5.50.4912.300" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT size=2>hi,</FONT></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT size=2>I try to use a call_external in an object method like
this:</FONT></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT face="Times New Roman" size=2>pro MCP2000__DEFINE<BR>&nbsp;struct =
{MCP2000, hComm: 0l, status: 0l}<BR>end<BR></FONT></DIV>
<DIV><FONT face="Times New Roman" size=2>function MCP2000::Init<BR>self.hComm =
0l<BR>return, 1<BR>end<BR></FONT></DIV>
<DIV><FONT face="Times New Roman" size=2>function
MCP2000::InitPort<BR> self.status=call_external('D:\Cpp\SerCommDll\Debug\SerCommDl l.dll','InitPortDll',$ <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;/PORTABLE,'COM1',self.hComm
,/UNLOAD)<BR>return, self.status<BR>end<BR></FONT></DIV>
<DIV><FONT size=2>the idea is here that self.hComm contains a valid handle, but
it doesnt - it stays zero.</FONT></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT size=2>However, this works</FONT></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT face="Times New Roman" size=2>function MCP2000::InitPort</FONT></DIV>
<DIV><FONT face="Times New Roman"
size=2>Temp=0l<BR> self.status=call_external('D:\Cpp\SerCommDll\Debug\SerCommDl l.dll','InitPortDll',$ <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
/PORTABLE,'COM1',Temp,/UNLOAD)</FONT></DIV>
<DIV><FONT face="Times New Roman" size=2>self.hComm=0l<BR>return,
self.status<BR>end</FONT></DIV>
<DIV><FONT face="Times New Roman"></FONT>&nbsp;</DIV>
<DIV><FONT size=2>any ideas what goes wrong in the first
function????</FONT></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT size=2>Gert</FONT></DIV>
<DIV><FONT size=2></FONT><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV></BODY></HTML>
Re: objects and call external [message #29353 is a reply to message #29273] Wed, 13 February 2002 06:18 Go to previous message
Gert Van de Wouwer is currently offline  Gert Van de Wouwer
Messages: 21
Registered: January 2002
Junior Member
ok I already got the answer: i cannot pass something like self.hComm by
reference (which was in the manual anyway...)




"Gert Van de Wouwer" <Gert.VandeWouwer@NOSPAMua.ac.be> wrote in message
news:a4dp0b$qib$1@naxos.belnet.be...
>
> all right, so passing is self.hcom is pass by value; passing hcomm is pass
> by reference. Is there a way to pass self.hcomm by reference; i.e. the
> c-analgo would be &(self.hcomm)...?
>
>
>
> "Mark Rivers" <rivers@cars.uchicago.edu> wrote in message
> news:RLla8.194$x4.4337@news.uchicago.edu...
>>
>> Gert <gert.van.de.wouwer@NO_SPAMpandora.be> wrote in message
>> news:SJea8.136468$rt4.12914@afrodite.telenet-ops.be...
>>> hi,
>>>
>>> I try to use a call_external in an object method like this:
>>
>>
>>> pro MCP2000__DEFINE
>>> struct = {MCP2000, hComm: 0l, status: 0l}
>>> end
>>
>>> function MCP2000::Init
>>> self.hComm = 0l
>>> return, 1
>>> end
>>
>>> function MCP2000::InitPort
>>>
>>
>
self.status=call_external('D:\Cpp\SerCommDll\Debug\SerCommDl l.dll','InitPort
>> Dll',$
>>> /PORTABLE,'COM1',self.hComm ,/UNLOAD)
>>> return, self.status
>>> end
>>>
>>> the idea is here that self.hComm contains a valid handle, but it
> doesnt -
>> it stays zero.
>>
>> Your problem has nothing to do with CALL_EXTERNAL or the fact that you
are
>> using an object method. The problem is that when you pass self.hComm
(to
>> any routine) IDL views that as an "expression" and passes a copy of
>> self.hComm, not the address of self.hComm. Thus you cannot modify
>> self.hComm in the called routine. It is analogous to C passing integers
> by
>> value - the called routine can write into the function parameter, but
the
>> calling routine does not see the resulting change. Your second way of
> doing
>> it is correct, pass "temp" and copy "temp" to self.hComm on the return.
>>
>> Mark Rivers
>>
>>
>>
>
>
Re: objects and call external [message #29361 is a reply to message #29273] Wed, 13 February 2002 05:18 Go to previous message
Gert Van de Wouwer is currently offline  Gert Van de Wouwer
Messages: 21
Registered: January 2002
Junior Member
all right, so passing is self.hcom is pass by value; passing hcomm is pass
by reference. Is there a way to pass self.hcomm by reference; i.e. the
c-analgo would be &(self.hcomm)...?



"Mark Rivers" <rivers@cars.uchicago.edu> wrote in message
news:RLla8.194$x4.4337@news.uchicago.edu...
>
> Gert <gert.van.de.wouwer@NO_SPAMpandora.be> wrote in message
> news:SJea8.136468$rt4.12914@afrodite.telenet-ops.be...
>> hi,
>>
>> I try to use a call_external in an object method like this:
>
>
>> pro MCP2000__DEFINE
>> struct = {MCP2000, hComm: 0l, status: 0l}
>> end
>
>> function MCP2000::Init
>> self.hComm = 0l
>> return, 1
>> end
>
>> function MCP2000::InitPort
>>
>
self.status=call_external('D:\Cpp\SerCommDll\Debug\SerCommDl l.dll','InitPort
> Dll',$
>> /PORTABLE,'COM1',self.hComm ,/UNLOAD)
>> return, self.status
>> end
>>
>> the idea is here that self.hComm contains a valid handle, but it
doesnt -
> it stays zero.
>
> Your problem has nothing to do with CALL_EXTERNAL or the fact that you are
> using an object method. The problem is that when you pass self.hComm (to
> any routine) IDL views that as an "expression" and passes a copy of
> self.hComm, not the address of self.hComm. Thus you cannot modify
> self.hComm in the called routine. It is analogous to C passing integers
by
> value - the called routine can write into the function parameter, but the
> calling routine does not see the resulting change. Your second way of
doing
> it is correct, pass "temp" and copy "temp" to self.hComm on the return.
>
> Mark Rivers
>
>
>
Re: objects and call external [message #29368 is a reply to message #29273] Tue, 12 February 2002 20:12 Go to previous message
Mark Rivers is currently offline  Mark Rivers
Messages: 49
Registered: February 2000
Member
Gert <gert.van.de.wouwer@NO_SPAMpandora.be> wrote in message
news:SJea8.136468$rt4.12914@afrodite.telenet-ops.be...
> hi,
>
> I try to use a call_external in an object method like this:


> pro MCP2000__DEFINE
> struct = {MCP2000, hComm: 0l, status: 0l}
> end

> function MCP2000::Init
> self.hComm = 0l
> return, 1
> end

> function MCP2000::InitPort
>
self.status=call_external('D:\Cpp\SerCommDll\Debug\SerCommDl l.dll','InitPort
Dll',$
> /PORTABLE,'COM1',self.hComm ,/UNLOAD)
> return, self.status
> end
>
> the idea is here that self.hComm contains a valid handle, but it doesnt -
it stays zero.

Your problem has nothing to do with CALL_EXTERNAL or the fact that you are
using an object method. The problem is that when you pass self.hComm (to
any routine) IDL views that as an "expression" and passes a copy of
self.hComm, not the address of self.hComm. Thus you cannot modify
self.hComm in the called routine. It is analogous to C passing integers by
value - the called routine can write into the function parameter, but the
calling routine does not see the resulting change. Your second way of doing
it is correct, pass "temp" and copy "temp" to self.hComm on the return.

Mark Rivers
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: XROI - how to invoke region growing
Next Topic: Re: Object method compiling

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

Current Time: Wed Oct 08 14:32:45 PDT 2025

Total time taken to generate the page: 0.00764 seconds