Thanks Jussi! It's nice to understand the language. I didn't say that there was a bug, my mind just did not go to the behavior of WRITE instruction, which it moved the stream pointer after writing the data.
I remade the example to show this detail for better comprehension. ------------------------------------- ' Gambas module file Public Sub Main() Dim pPointer As Pointer Dim hMemory As Stream Dim iA As Integer pPointer = Alloc(SizeOf(gb.Integer)) hMemory = Memory pPointer For Read Write Write #hMemory, 10 As Integer 'get stream pointer position Print Seek(hMemory) '4 'set stream pointer potition Seek #hMemory, 0 'get stream pointer position Print Seek(hMemory) '0 'read from memory stream iA = Read #hMemory As Integer Print iA '10 'read from address iA = Integer@(pPointer) Print iA '10 Free(pPointer) End ------------------------------------- something else, as i read the docs i found a way to write to a pointer by instructions hMemory = Memory pPointer For Read Write Write #hMemory, 10 As Integer is there any other way that i did not notice? there is also PRINT to stream but as i see it converts the expression to string with Str$, so it is not a good option. On Sat, 2011-01-08 at 20:43 +0200, Jussi Lahtinen wrote: > Argh... of course: > > This uses internal counter: > iA = Read #hMemory As Integer > > This uses pPointer as address: > iA = Integer@(pPointer) > > > Jussi > > > On Sat, Jan 8, 2011 at 20:40, Jussi Lahtinen <jussi.lahti...@gmail.com>wrote: > > > Behaviour confirmed with Gambas 3 rev 3447 @ Ubuntu 10.10 64bit. > > Though I don't think this is bug, since stream pointer position moves after > > write. > > "Seek #hMemory, 0" will fix that, in this case. See more from documentation > > of Seek. > > > > However I don't know how Interger@ gets correct position... > > > > Jussi > > > > > > > > > > > > On Sat, Jan 8, 2011 at 18:09, Demosthenes Koptsis > > <demosthen...@gmail.com>wrote: > > > >> > >> But if i write, > >> > >> iA = Integer@(pPointer) > >> Print iA > >> > >> then iA gets the value 10. > >> > >> why is that? > >> > >> what's the difference between > >> iA = Read #hMemory As Integer > >> iA = Integer@(pPointer) > >> > >> ? > >> -- > >> Regards, > >> Demosthenes Koptsis. > >> > >> > >> ---------- Forwarded message ---------- > >> From: Demosthenes Koptsis <demosthen...@gmail.com> > >> To: Gambas User List <gambas-user@lists.sourceforge.net> > >> Date: Sat, 08 Jan 2011 10:32:12 +0200 > >> Subject: Gambas3 Pointers example > >> Hello, > >> i remake an example for pointers in Gambas3-svn3432, ubuntu 10.04 LTS, > >> AMD64 > >> > >> The example is the next: > >> > >> ------------------------- > >> ' Gambas module file > >> > >> Public Sub Main() > >> > >> Dim pPointer As Pointer > >> Dim hMemory As Stream > >> Dim iA As Integer > >> > >> pPointer = Alloc(SizeOf(gb.Integer)) > >> hMemory = Memory pPointer For Read Write > >> > >> Write #hMemory, 10 As Integer > >> iA = Read #hMemory As Integer > >> > >> Print iA > >> > >> Free(pPointer) > >> > >> End > >> ------------------------- > >> > >> the iA var when it prints is not 10 but something else like 0 or 32621 > >> or similar. > >> > >> What am i doing wrong? > >> > >> > >> > >> -- > >> Regards, > >> Demosthenes Koptsis. > >> > >> > >> ------------------------------------------------------------------------------ > >> Gaining the trust of online customers is vital for the success of any > >> company > >> that requires sensitive data to be transmitted over the Web. Learn how > >> to > >> best implement a security strategy that keeps consumers' information > >> secure > >> and instills the confidence they need to proceed with transactions. > >> http://p.sf.net/sfu/oracle-sfdevnl > >> _______________________________________________ > >> Gambas-user mailing list > >> Gambas-user@lists.sourceforge.net > >> https://lists.sourceforge.net/lists/listinfo/gambas-user > >> > >> > > > ------------------------------------------------------------------------------ > Gaining the trust of online customers is vital for the success of any company > that requires sensitive data to be transmitted over the Web. Learn how to > best implement a security strategy that keeps consumers' information secure > and instills the confidence they need to proceed with transactions. > http://p.sf.net/sfu/oracle-sfdevnl > _______________________________________________ > Gambas-user mailing list > Gambas-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/gambas-user -- Regards, Demosthenes ------------------------------------------------------------------------------ Gaining the trust of online customers is vital for the success of any company that requires sensitive data to be transmitted over the Web. Learn how to best implement a security strategy that keeps consumers' information secure and instills the confidence they need to proceed with transactions. http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user