[Gambas-user] Minor bug with READ & WRITE commands?

nando nando_f at ...951...
Fri Jan 16 19:51:37 CET 2009


Benoit,
Question regarding the line:
> > WRITE #pResult + (ii * 8), .x
does WRITE see it casted as variant or int ?
-Fernando


---------- Original Message -----------
From: Benoit Minisini <gambas at ...1...>
To: mailing list for gambas users <gambas-user at lists.sourceforge.net>
Sent: Fri, 16 Jan 2009 03:50:16 +0100
Subject: Re: [Gambas-user] Minor bug with READ & WRITE commands?

> 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 at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
------- End of Original Message -------





More information about the User mailing list