Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sat Sep 21, 2019 4:29 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Using external function en RB
PostPosted: Mon Dec 19, 2011 8:46 am 
Offline

Joined: Sat Oct 22, 2011 6:00 pm
Posts: 15
I'm using a function whose documentation indicates that the function declaration in Visual Basic is:

Declare Function FSDKVB_GetCameraList Lib "facesdk-vb.dll" (ByRef VCameraList As Variant, ByRef CameraCount As Long) As Long

This function returns an array of strings in the variable VCameraList, how should I declare the variable VCameraList in RB?

Best regards.

_________________
Hector Gonzalez


Top
 Profile  
Reply with quote  
 Post subject: Re: Using external function en RB
PostPosted: Mon Dec 19, 2011 9:09 am 
Offline
User avatar

Joined: Fri Nov 10, 2006 4:10 pm
Posts: 1855
Location: Michigan, USA
Is it an array of strings or a structure of a set number of string of a set size?

If it's an array of string there's no reason you can't simply use ByRef VCameraList As String, where VCameraList = String() — declared in code as Dim VCameraList() As String.

Hope this helps. :)

_________________
Windows 8 x64
Windows XP Pro SP3
Ubuntu 11.04 via Virtual Box
RS Enterprise 2012r1.1

Programming Tutorials & Free Projects: http://www.JasonTheAdams.com
"Christianity has not been tried and found wanting; it has been found difficult and not tried." - G.K. Chesterton


Top
 Profile  
Reply with quote  
 Post subject: Re: Using external function en RB
PostPosted: Mon Dec 19, 2011 9:27 am 
Offline

Joined: Sat Oct 22, 2011 6:00 pm
Posts: 15
If I declare the variable as

Dim VCameralist () as String

I get an error indicating that the external function only accepts CString types, but if you declare the variable as

Dim VCameralist () AS CString

I get that type can not be used as a array

_________________
Hector Gonzalez


Top
 Profile  
Reply with quote  
 Post subject: Re: Using external function en RB
PostPosted: Mon Dec 19, 2011 9:39 am 
Offline
User avatar

Joined: Fri Nov 10, 2006 4:10 pm
Posts: 1855
Location: Michigan, USA
Hmm, does it work with the variant then?

Try:

Declare Function FSDKVB_GetCameraList Lib "facesdk-vb.dll" (ByRef VCameraList As Variant, ByRef CameraCount As Long) As Long

Dim vList As Variant
Dim List() As String
Dim Result, Count As Int64

Result = FSDKVB_GetCameraList(vList, Count)

If vList.IsArray Then
List = vList
Else
// Something is wrong
End If

_________________
Windows 8 x64
Windows XP Pro SP3
Ubuntu 11.04 via Virtual Box
RS Enterprise 2012r1.1

Programming Tutorials & Free Projects: http://www.JasonTheAdams.com
"Christianity has not been tried and found wanting; it has been found difficult and not tried." - G.K. Chesterton


Top
 Profile  
Reply with quote  
 Post subject: Re: Using external function en RB
PostPosted: Mon Dec 19, 2011 11:48 am 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
Use a MemoryBlock. The question to ask is, Who allocates the memory? You or the DLL? If you do, there will be a form of the call that calculates the amount of memory needed and passes it back to you so you can allocate a chunk of memory long enough. If the DLL, then there will be a call to deallocate/free up the memory. In either case, you should expect a chunk of memory (a MemoryBlock) that contains an array of pointers followed by the CString data itself, one after another. Use the pointers to get to each string.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 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