[Gambas-user] gb3: writing variables to a string using a memory stream and pointer

tobias tobiasboe1 at ...20...
Sun Sep 11 14:19:19 CEST 2011


On 11.09.2011 06:40, Kevin Fishburne wrote:
> My code looks like this:
>
> ' For writing outgoing UDP data to memory.
> Public data As String
> Public mem As Stream
>
> ' Create data string for outgoing transaction queue.
> data = Space(8)
> mem = Memory VarPtr(data) For Write
> mem.Begin
>     Write #mem, (Server.DateCurrent + Server.DateUTC) As Float
> mem.Send
> Print data
>
> It throws signal 11 on the Print statement.
>
> I have two questions. First is this the correct way to write one or more
> variables to a string in memory, and second what's up with the signal
> 11? I'm using revision 4094 and will update to the newest revision in a
> moment.
>
you know about sig 11? it means you attempted to access memory which you 
are not peritted to access the way you wanted.
you may want to have a look at the notes about VarPtr(string) here: 
http://gambasdoc.org/help/lang/varptr?v3
of course, it's much better to use Alloc() and work with a pointer as 
Jussi said.




More information about the User mailing list