[Gambas-user] Saving & Loading multible Variables
Benoit Minisini
gambas at ...1...
Mon Jan 9 20:01:19 CET 2006
On Monday 09 January 2006 19:12, Scott wrote:
> Hi again,
>
> I found a walk around my problem with saving and loading multiple
> variables. It is simple to save and load a single variable, so I simply
> saved each variable to a different file. It is a little messy, but it
> works; and in the end that is what really matters :) If anyone can
> still tell me how to save multiple variables into a single file, that
> would be nice.
>
> I have placed the code down I used in a test program that works just
> in case other people are having the same problem and don't mind my quick
> fix to this problem. I even added a bit in to save the files to a
> specific folder and to create that folder if it does not exist.
>
> PUBLIC SUB Save_Click()
>
> DIM a AS String
> DIM b AS String
> DIM c AS String
> DIM d AS String
> DIM fe AS Boolean
>
> fe = Exist ( system.Home &/"savetest" )
> IF fe = FALSE THEN MKDIR system.Home &/"savetest"
>
> a = textbox1.Text
> b = textbox2.Text
> c = textbox3.Text
> d = textbox4.Text
>
> File.Save(system.Home &/"savetest/testa.txt", a)
> File.Save(system.Home &/"savetest/testb.txt", b)
> File.Save(system.Home &/"savetest/testc.txt", c)
> File.Save(system.Home &/"savetest/testd.txt", d)
>
> END
>
> PUBLIC SUB Load_Click()
>
> DIM a AS String
> DIM b AS String
> DIM c AS String
> DIM d AS String
>
> a = File.Load(system.Home &/"savetest/testa.txt")
> b = File.Load(system.Home &/"savetest/testb.txt")
> c = File.Load(system.Home &/"savetest/testc.txt")
> d = File.Load(system.Home &/"savetest/testd.txt")
>
> textbox5.Text = a
> textbox6.Text = b
> textbox7.Text = c
> textbox8.Text = d
>
> END
My God!
You can use the Settings class, if you need to save some settings of your
application.
Anyway, look at the file management functions to see how to open a file, read
or write as much information you need, in binary or text format, and close it
when you have finished with the file.
Regards,
--
Benoit Minisini
More information about the User
mailing list