[Gambas-user] Saving & Loading multible Variables

Scott sclewin at ...1126...
Mon Jan 9 19:12:03 CET 2006


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

-- 
Your friend,
Scott

"Do to others as you would have them do to you."
Luke 6:31





More information about the User mailing list