[Gambas-user] saving files
Benoit Minisini
gambas at ...1...
Wed Dec 29 11:09:49 CET 2004
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 ?
Regards,
--
Benoit Minisini
mailto:gambas at ...1...
More information about the User
mailing list