Here they are. I included also "C-function.tar.gz", it contains source code (and binary) of shared library that ExtrnTEST uses. It is compiled with Code::Blocks. For some reason Code::Blocks forgets compiling option -fPIC when doing debug version (!??), so it's release version.
These projects exist only for test purpose! Jussi On Fri, Jan 16, 2009 at 4:50 AM, Benoit Minisini <gam...@users.sourceforge.net> wrote: > On jeudi 15 janvier 2009, Jussi Lahtinen wrote: >> Hi! >> >> Here is my test code (first with errors) for pass array of objects >> byref to external function: >> >> PUBLIC SUB Button4_Click() >> DIM ii AS Integer >> DIM pResult AS Pointer >> DIM fResult AS NEW Object[] >> DIM aa AS Class1 >> >> FOR ii = 0 TO 9 >> aa = NEW Class1 >> aa.x = 100 >> aa.y = 200 >> fResult.Add(aa) >> NEXT >> >> pResult = Alloc(8, 10) >> >> FOR ii = 0 TO 9 >> WITH fResult[ii] >> WRITE #pResult + (ii * 8), .x >> WRITE #pResult + ((ii * 8) + 4), .y >> END WITH >> NEXT >> >> GetAStruct(pResult) >> >> FOR ii = 0 TO 9 >> WITH fResult[ii] >> READ #pResult + (ii * 8), .x >> READ #pResult + ((ii * 8) + 4), .y >> END WITH >> NEXT >> >> Free(pResult) >> >> FOR ii = 0 TO 9 >> PRINT fResult[ii].x & " " & fResult[ii].y >> NEXT ' >> >> END >> >> >> Line: READ #pResult + (ii * 8), .x >> Gives error; Type mismatch: wanted Integer, got String instead. ?? >> >> And line: WRITE #pResult + (ii * 8), .x >> Writes rubbish into memory. No error messages. >> >> If I change code this way, it works perfectly: >> >> PUBLIC SUB Button4_Click() >> DIM ii AS Integer >> DIM pResult AS Pointer >> DIM fResult AS NEW Object[] >> DIM aa AS Class1 >> DIM kk AS Integer >> >> FOR ii = 0 TO 9 >> aa = NEW Class1 >> aa.x = 100 >> aa.y = 200 >> fResult.Add(aa) >> NEXT >> >> >> pResult = Alloc(8, 10) >> >> FOR ii = 0 TO 9 >> WITH fResult[ii] >> kk = .x >> WRITE #pResult + (ii * 8), kk >> kk = .y >> WRITE #pResult + ((ii * 8) + 4), kk >> END WITH >> NEXT >> >> GetAStruct(pResult) >> >> FOR ii = 0 TO 9 >> WITH fResult[ii] >> READ #pResult + (ii * 8), kk >> .x = kk >> READ #pResult + ((ii * 8) + 4), kk >> .y = kk >> END WITH >> NEXT >> >> Free(pResult) >> >> FOR ii = 0 TO 9 >> PRINT fResult[ii].x & " " & fResult[ii].y >> NEXT ' >> >> END >> >> >> Strange thing is that the whole code has no string on it. >> Class1: >> PUBLIC x AS Integer >> PUBLIC y AS Integer >> >> >> So, why .x is "string" ? >> Is there better way to do this (@ Gambas2.10.2)? >> >> >> Jussi >> > > Can you send me a source archive of that project? > > -- > Benoit Minisini > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > SourcForge Community > SourceForge wants to tell your story. > http://p.sf.net/sfu/sf-spreadtheword > _______________________________________________ > Gambas-user mailing list > Gambas-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/gambas-user >
ExtrnTEST-0.0.1.tar.gz
Description: GNU Zip compressed data
C-functions.tar.gz
Description: GNU Zip compressed data
------------------------------------------------------------------------------ This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user