Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Mon Oct 15, 2018 5:12 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Problem with mThis
PostPosted: Mon Apr 30, 2012 9:33 pm 
Offline

Joined: Fri Jun 09, 2006 3:52 pm
Posts: 62
Location: Montréal (Québec) Canada
Hi guys


I am trying to adapt some code from VB to RB. The main problem I have is with the following lines:

If mThis = Nil Then Raise New NilObjectException
Dim disp As New COM.IDispatch(mThis)

RB is showing errors with mThis. Does any of you have any ideas what mThis does and how to implement it in RB?


Thanks


Rick


Top
 Profile  
Reply with quote  
 Post subject: Re: Problem with mThis
PostPosted: Mon Apr 30, 2012 10:34 pm 
Offline
User avatar

Joined: Sun Aug 12, 2007 10:10 am
Posts: 1086
Location: Boiling Springs, SC
rhille wrote:
Hi guys


I am trying to adapt some code from VB to RB. The main problem I have is with the following lines:

If mThis = Nil Then Raise New NilObjectException
Dim disp As New COM.IDispatch(mThis)

RB is showing errors with mThis. Does any of you have any ideas what mThis does and how to implement it in RB?


Thanks


Rick


With the code taken out of context it will be impossible to determine what mThis is as it could be any datatype. mThis is not a native VB data structure so it could be any of the datatypes found at

http://msdn.microsoft.com/en-us/library ... 20(v=vs.60).aspx

Perhaps if you could prove more code (the original...I see you already tried transposing it...nilobject is not vb native :-p) which this was taken from it would be easier to help.

_________________
Matthew A. Combatti
Real Studio 2012 r1.2

Visit Xojo Developer's Spot!
Systems I Use:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS

~All Xojo Compatible~


Top
 Profile  
Reply with quote  
 Post subject: Re: Problem with mThis
PostPosted: Mon Apr 30, 2012 10:36 pm 
Offline
User avatar

Joined: Sun Aug 12, 2007 10:10 am
Posts: 1086
Location: Boiling Springs, SC
is this the code you are trying to translate?

Function mfReadHex(nBlock_Param As Int16, szData_Param As Ptr) As Boolean

If mThis = Nil Then Raise New NilObjectException
Dim disp As New COM.IDispatch(mThis)
Call disp.AddRef
Dim memID As Integer = 29
If memID = -1Then Raise New COM.COMException("Failed on mfReadHex", -1)
Dim params As COM.DISPPARAMS
Dim Local_nBlock_Param As MemoryBlock = COM.RBVariantToVARIANT(nBlock_Param)
params.cArgs = params.cArgs + 1
Dim Local_szData_Param As MemoryBlock = COM.RBVariantToVARIANT(szData_Param)
params.cArgs = params.cArgs + 1
Dim mbParams As New MemoryBlock(params.cArgs * COM.SIZEOF_VARIANT)
params.rgvarg = mbParams
If Local_nBlock_Param <> Nil Then mbParams.StringValue(1 * COM.SIZEOF_VARIANT, COM.SIZEOF_VARIANT) = Local_nBlock_Param.StringValue(0, COM.SIZEOF_VARIANT)
If Local_szData_Param <> Nil Then mbParams.StringValue(0 * COM.SIZEOF_VARIANT, COM.SIZEOF_VARIANT) = Local_szData_Param.StringValue(0, COM.SIZEOF_VARIANT)
Dim resultCode As Integer
Dim result As New MemoryBlock(COM.SIZEOF_VARIANT)
Dim err As UInt32
Dim mb As New MemoryBlock(params.Size)
mb.LittleEndian = True
mb.StringValue(0,params.Size) = params.StringValue(True)
resultCode = disp.Invoke(memID, COM.IID_NULL, COM.LOCALE_USER_DEFAULT, COM.DISPATCH_METHOD + COM.DISPATCH_PROPERTYGET, mb, result, nil, err)
COM.FreeVARIANT(Local_nBlock_Param)
COM.FreeVARIANT(Local_szData_Param)
If resultCode = COM.S_OK Then
Dim retVal As Variant = COM.VARIANTToRBVariant(result)
COM.FreeVARIANT(result)
Return retVal
Else // Throw Exception
Raise New COM.COMException("Failed on mfReadHex", resultCode)
End If



See the following two post

viewtopic.php?f=6&t=40577&p=226076&hilit=COM.IDispatch#p226076

Implementing COM in RB
http://web.archive.org/web/200903101820 ... basic.html

_________________
Matthew A. Combatti
Real Studio 2012 r1.2

Visit Xojo Developer's Spot!
Systems I Use:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS

~All Xojo Compatible~


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group