his is some code I have been playing around with.
// The character UDT
type CharacterType
name as string
race as string
class as string
endtype
// The UDT array to hold the character. This one will hold 3
dim character(5) as CharacterType
// count the number of characters
index = 0
do
input "would you like to create a new character? y/n ",a$
if a$ = "y"
inc index,1
input "Enter a name for your character ", character(index).name
input "Enter a race for your character ", character(index).race
input "What class would you like your character to be? ", character(index).class
endif
print
for i = 1 to index
print "Your name is ", character(index).name
print "You are a ", character(index).race
print "You are a ", character(index).class
NEXT i
print
if a$ = "n"
//quit program
end
endif
LOOP
// Write to disk
filename$ = "GameCharacters"
if file exist(filename$)=1 then delete file filename$
open to write 1, filename$
write word 1,index
for i = 1 to index
write string 1, character(i).name
write string 1, character(i).race
write string 1, character(i).class
next i
close file 1
// Read from disk
if file exist(filename$)=1
open to read 1, filename$
read word 1, index
endif
for i = 1 to index
read string 1, character(i).name
read string 1, character(i).race
read string 1, character(i).class
next i
close file 1
I have been having some problems understanding file commands. I am understanding a little better but I want to test it and can't quite figure out how. I have tried print commands but can't get anything to print out.
What I want to do is make a character, exit the program start the program with the exe see the character I made before and then make a new character and see that one the next time I start. I just can't seem to get it to work.
I want the player to be able to create a bunch of characters, a list of characters with attributes and stats and stuff. I want them to be able to call that list up and pick a character to add to a party. I am pretty sure I need to store that character list in a file.
Thanks
Dragonslayer