[Gambas-user] saving files

Jochen Georges jochengeorges at ...467...
Wed Dec 29 15:51:51 CET 2004


On Wednesday 29 December 2004 11:09, Benoit Minisini wrote:
> On Wednesday 29 December 2004 08:20, Jochen Georges wrote:
> > Hello gambanauts,
> >
> > i would like to save an object of a selfdefined class into a file, just
> > like
> > http://www.binara.com/gambas-wiki/bin/view/Gambas/MiscFilesMydatatype
> >
> > But this does not work ??
> > ------------------------------------------------------------------------
> > PUBLIC mc AS MyClass
> >
> > PUBLIC SUB _new()
> >   mc = NEW MyClass
> > END
> >
> > PUBLIC SUB Button1_Click()
> >   myFile AS File
> >   OPEN "/home/jochen/test.mcf" FOR CREATE AS myFile
> >     'mc.WriteTo(myFile) 'unknown symbol 'WriteTo' in class 'MyClass'
> >       'but it works in the wiki-example !?
> >       'can't find information about WriteTo
> >     'WRITE myFile,mc 'Type mismatch: wanted Integer Type, got MyClass
> > instead WRITE #myFile,mc 'Type mismatch: wanted Standard Type, got
> > MyClass instead CLOSE myFile
> > END
> > ------------------------------------------------------------------------
> > 'MyClass.class:
> > wort AS String
> > zahl AS Integer
> >
> > PUBLIC SUB _new()
> >  wort = "Hallo"
> >  zahl = 3
> > END
> > ------------------------------------------------------------------------
> >
> > Thanks for any hint.
> >
> > Beste Gruesse
> > Jochen
>
> Gambas object are not (yet) serializable. So, if you want to write them
> into a file, you must do it yourself. For example, by implementing a
> 'WriteTo' method in the class ?

Hi Benoit,

Why does it work in the wikiexample ??
In the class CCar is no method WriteTo !!

How does a method WriteTo look like?

Thanks for any hint.

Jochen





More information about the User mailing list