Just as Ortu says.
Here's a small example:
rem these are variables which have to be saved
global name$ as string
global age as integer
rem check if the save file exists or not
if file exist( "save.dat" ) = 0
rem ok, the game hasn't been save yet. Get the information from the user by seducing him
print "Why hello there, my strong, masculine boy."
input "Do you have a name? -- ", name$
rem it worked! Seduce him more and get his age
print name$ + "? That's a wonderfully charming name."
print "What is your age? -- ", age
rem yes! good! keep him distracted while we save the game
print "So you're " + str$(age) + ", huh?"
print name$ + ", we have a lot in common"
rem SAVE
rem (note: ALWAYS check if the file exists yet or not in your game.
rem If you try to write to a file which already exists, your program will crash.
rem If you want to overwrite an existing save file, use the command "delete file" before creating the new file.
rem we already checked if the file exists or not above, so doing it here again would be redundant)
open to write 1, "save.dat"
rem write the data to the file
write string 1, name$
write long 1, age
close file 1
rem oh oh! Excuse time! ABORT ABORT
print "err... OH GOD, I totally forgot I left my oven in the bread!" : wait 300
print " [organic computer] Lie detector activated"
print " [organic computer] ...translating..." : wait 500
print " [organic computer] translation complete: She hates you." : wait 1000
print "I have to go!"
print
rem end
print "(OK, now run this program again)"
wait key
end
endif
rem save file exists
if file exist( "save.dat" )
rem read in saved data
open to read 1, "save.dat"
read string 1, name$
read long 1, age
close file 1
rem tell the user he is hated
print name$ + "?? What are you doing here?"
print name$ + ", your age of " + str$(age) + " sucks."
print "would you like to changed your name?"
input " enter new name -- ", name$
input " enter new age -- ", age
rem you can save data here again
delete file "save.dat"
open to write 1, "save.dat"
write string 1, name$
write long 1, age
close file 1
print "new data:"
print "name: " + name$
print "age: " + str$(age)
wait key
end
endif
TheComet