[Gambas-user] Error message from (at least earlier valid) pointer usage.

Jussi Lahtinen jussi.lahtinen at ...626...
Sat Sep 19 01:33:55 CEST 2009


OK, now it works! Thanks!
That makes my code more simple than it was, very good!
Only one little disruptive thing... using "File" is little counter
intuitive, but maybe I just don't name it "hFile",
maybe instead "hMyData" or like.

Must go to sleep...

Jussi


2009/9/19 Benoît Minisini <gambas at ...1...>:
>> 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
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry® Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9-12, 2009. Register now!
> http://p.sf.net/sfu/devconf
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>




More information about the User mailing list