Ok, I have worked in your advice, and it's working better now, but there's still some problems. I'm going to post my entire code so far.
global fileone as string = "Empty"
global filetwo as string = "Empty"
global filethree as string = "Empty"
global gamename as string = ""
if file exist("save.txt") = 0
open to write 1, "save.txt"
write string 1, fileone
write string 1, filetwo
write string 1, filethree
close file 1
endif
fileone = ""
filetwo = ""
filethree = ""
open to read 1, "save.txt"
read string 1, fileone
read string 1, filetwo
read string 1, filethree
close file 1
loginvarone as string = "New Game"
loginvartwo as string = "Erase Game"
introchoice as integer = 1
introchoiceamount as integer = 5
lastkey as string = ""
enterbutton as string = chr$(13)
upbutton as string = chr$(119)
downbutton as string = chr$(115)
do
lastkey = inkey$()
cls
if (introchoice = 1)
print "> "; loginvarone
print " "; fileone
print " "; filetwo
print " "; filethree
print " "; loginvartwo
endif
if (introchoice = 2)
print " "; loginvarone
print "> "; fileone
print " "; filetwo
print " "; filethree
print " "; loginvartwo
endif
if (introchoice = 3)
print " "; loginvarone
print " "; fileone
print "> "; filetwo
print " "; filethree
print " "; loginvartwo
endif
if (introchoice = 4)
print " "; loginvarone
print " "; fileone
print " "; filetwo
print "> "; filethree
print " "; loginvartwo
endif
if (introchoice = 5)
print " "; loginvarone
print " "; fileone
print " "; filetwo
print " "; filethree
print "> "; loginvartwo
endif
if (upkey() = 1)
keypressed(lastkey)
if (introchoice > 1)
introchoice = (introchoice - 1)
endif
endif
if (downkey() = 1)
keypressed(lastkey)
if (introchoice < introchoiceamount)
introchoice = (introchoice + 1)
endif
endif
if (returnkey() = 1)
keypressed(lastkey)
if (introchoice = 1) then newgame()
`if (introchoice = 2 or 3 or 4) then loadgame()
`if (introchoice = 5) then erasegame
endif
loop
wait key
end
Function newgame()
cls
if fileone <> "Empty" and filetwo <> "Empty" and filethree <> "Empty"
print "All files are taken. Delete one and try again."
wait key
exitfunction
endif
input "Enter a name: ", gamename
if fileone = "Empty" then fileone = gamename : gamename = "Empty"
if filetwo = "Empty" then filetwo = gamename : gamename = "Empty"
if filethree = "Empty" then filethree = gamename : gamename = "Empty"
if (file exist("save.txt") = 1) then delete file "save.txt"
open to write 1, "save.txt"
write string 1, fileone
write string 1, filetwo
write string 1, filethree
close file 1
print "File created. Press any key to continue."
wait key
lastkey as string = inkey$()
keypressed(lastkey)
Endfunction
function keypressed(key as string)
if key = inkey$()
do
if key <> inkey$() then exitfunction
loop
endif
exitfunction
endfunction
Alright, firstly, It's not having any trouble
reading the save file, or initially creating it/writing it, but when I make a new file, although it shows up within the program, it never gets written to the save file. Any help?
EDIT: Fixed this problem, the saving works now.
Secondly, I was experiencing a problem with the main menu, where, as soon as you hit a key, it just zooms through everything to the end. For example, if you hit the down key, it would just fly down to the bottom choice.
To fix it, I wrote the keypressed function, but now there's a different problem. Whenever I hit something, I have to hit something else to make it happen. For instance, if I hit the down arrow key, nothing happens, but if I then hit a letter key, it then recognizes my down key. It's almost like there's a wait key in there. Run it and you'll see what I mean. I think the keypressed function is causing this but I'm not positive. Any help would be appreciated.