[Gambas-user] Error message from (at least earlier valid) pointer usage.
Benoît Minisini
gambas at ...1...
Sat Sep 19 01:01:00 CEST 2009
> This code, gives error message "wanted Stream got Long instead":
>
> pPOINTS = Alloc(4, 1522)
> tmp = CalculatePoints(pPOINTS,matrix.Data)
>
> ....
>
> For ii = 0 To tmp
> tmpPOINT = New POINT
> Read #pPOINTS + (ii * 4), tmpPOINT.x <---- Fails here!
> Read #pPOINTS + (ii * 4) + 2, tmpPOINT.y
> ...
>
> POINT class:
>
> Public x As Short = -1
> Public y As Short
>
> There is also rather complicated "_compare" function, but I don't
> think it matters with this problem.
>
>
> This code worked fine with earlier Gambas 3 revisions.
> Does this has anything to do with my error?
> * NEW: A Pointer can not be used as a stream directly. You must use the
> new Memory instruction for that.
>
> New feature understandably lacks documentation, so I need help!
>
> Jussi
>
Sorry, all that is work in progress.
I am currently redoing the way Gambas deals with binary data.
So now, to access memory located at a specific pointer, you must do:
Dim pPoints as Pointer
Dim hFile AS File
hFile = Memory pPoints For Read ' or For Write
...
Close #hFile
Then you use the READ instruction normally, except that hFile has an internal
memory pointer that is automatically incremented.
The first time, the data is read at address pPoints. But if, for example, you
read 4 bytes, the next read will occur at address pPoints + 4. And so on until
the end of the memory or a memory access error.
The syntax of READ and WRITE will change too, and there is an high risk that
the bytecode format changes, and that projects need to be recompiled.
Regards,
--
Benoît Minisini
More information about the User
mailing list