[Gambas-user] Segmentation Fault - Deserialization

Gianluigi bagonergi at gmail.com
Thu Jul 16 22:58:14 CEST 2020


Il giorno gio 16 lug 2020 alle ore 21:10 T Lee Davidson <
t.lee.davidson at gmail.com> ha scritto:

> On 7/16/20 1:24 PM, Gianluigi wrote:
> > But in the wiki it says "as Object" or "as Variant" if you change to
> Variant it works.
> >...
> Where are you seeing the Wiki say "as Object" or "as Variant"? I haven't
> found that.
>
>
Hi Lee,

I read it here:
http://gambaswiki.org/wiki/lang/write

Here with Class1 this code works.
'-----------------------------------------
' Gambas module file

Private hFile As File
Private hObj As New Class1

Public Sub Main()

  ' Once the file has been written, you can also Try To read (Leggi) it
only, commenting On Scrivi (Write)
  Scrivi ' Write in italian
  Leggi ' Read ...

End

Private Sub Scrivi()

  ' Dim hFile As File
  ' Dim hObj As New Class1

  hFile = Open "/tmp/TestReadWrite" For Write Create
  hObj.Name = "TestReadWrite"
  hObj.Bird = Date(Now)
  Write #hFile, hObj As Object ' or variant
  Close #hFile

End

Private Sub Leggi()

  ' Dim hFile As File
  ' Dim hObj As New Class1 ' The object must refer to the class otherwise
it causes an error.

  hFile = Open "/tmp/TestReadWrite" For Read
  hObj = Read #hFile As Variant ' or object
  Print "The file is named "; Quote(hObj.Name); " and it is created the: ";
Format(hObj.Bird, gb.LongDate)  ' Print the name and date on the console
  Close #hFile

End
'------------------------------------------------

Regards
Gianluigi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20200716/6366a3b9/attachment-0001.html>


More information about the User mailing list