[Gambas-user] Migrate VB6 project to Gambas 2.0 ?

Ron Onstenk ronstk at ...239...
Tue Feb 19 06:25:30 CET 2008


On Tuesday 19 February 2008 03:55, 2020 wrote:
> 
> Benoit Minisini wrote:
> > 
> > On samedi 9 février 2008, 2020 wrote:
> >> Hello folk,
> >>
> >> I am trying to migrate a VB6 project to Gambas 2.0.
> >>
> >> My VB6 project require ftd2xx.dll, but in xubuntu 7.10 I will used
> >> ftdi_sio
> >> driver (FTDI USB Serial Device converter).
> >>
> >> All I want to do is to call FTDI functions from Gambas 2.0 project.
> >>
> >> Snippet code from my VB6 project;
> >> Private Declare Function FT_Open Lib "FTD2XX.DLL" (ByVal intDeviceNumber
> >> As
> >  Integer, ByRef lngHandle As Long) As Long
> >>
> >> Any ideas, thanks in advance.
> >>
> >> Sylvain.
> > 
> > You must tell me the prototype of the function in C to be sure. So the 
> > following *may* work:
> > 
> > It is a bit complicated in Gambas 2, because VarPtr() exists only in
> > Gambas 3.
> > 
> > --8<---------------------------
> > 
> > PRIVATE EXTERN FT_Open(intDeviceNumber AS Integer, plngHandle AS Pointer)
> > AS 
> > Integer
> > 
> > ...
> > 
> > DIM plngHandle AS Pointer = Alloc(8)
> > DIM lngHandle AS Integer
> > DIM iRet AS Integer
> > 
> > iRet = FT_Open(..., plngHandle)
> > READ #plngHandle, lngHandle
> > 
> > --8<---------------------------
> > 
> > Tell me if it works.
> > 
> > Regards,
> > 
> > -- 
> > Benoit Minisini
> > 
> > -------------------------------------------------------------------------
> > This SF.net email is sponsored by: Microsoft
> > Defy all challenges. Microsoft(R) Visual Studio 2008.
> > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> > _______________________________________________
> > Gambas-user mailing list
> > Gambas-user at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> > 
> > 
> 
> Bonjour Benoit, 
> 
> Q1: What do you mean by "prototype of the function in C" in your first
> statement.
> 
> Test1; 
> 
> The open device function works fine, but the close device function failed
> ... return code 1 (invalid handle).
> 
> For more details ---> 
> http://www.nabble.com/file/p15550851/test1%2Bopen%2Bdmx%2Busb.png  
> http://www.nabble.com/file/p15550851/test1%2Bopen%2Bdmx%2Busb.txt
> test1+open+dmx+usb.txt 
> 
> Thanks in advance,
> Sylvain.
> 
> 

You did use 'DIM plngHandle AS Pointer' in both sub routines.
The function Open does have its own handle and calling the Close 
function creates his own new one for close and on assign 
iRet = FT_Open() it is not initialized and a open handle.

You should put in the head of your class PRIVATE plngHandle AS Pointer
Prefer to do it below the to EXTERN lines in this case.

Ron






More information about the User mailing list