This code puts the name of a monster and some of the monster's stats in a file to retrieve for later use in the program. But it doesn't seem to record it correctly. Can some of you look through this and try to find out what's not working correctly?
if file exist("psdb.pbc")
open to read 1,"psdb.pbc"
read file 1,nop
dim name$(nop+1)
dim hpbase(nop+1)
dim attbase(nop+1)
dim defbase(nop+1)
dim spabase(nop+1)
dim spdbase(nop+1)
dim spebase(nop+1)
for q=1 to nop
read string 1,name$(q)
read file 1,hpbase(q)
read file 1,attbase(q)
read file 1,defbase(q)
read file 1,spabase(q)
read file 1,spdbase(q)
read file 1,spebase(q)
next q
close file 1
else
make file "psdb.pbc"
endif
cfn:
cls
input "Name of Monster (Case sensitive): ",nn$
print "Searching for ",nn$
for w=1 to nop
if nn$=name$(w) then goto found
next w
print nn$,"could not be found. Would you like to add ",nn$," to the database? (Y/N)"
do
if keystate(21)=1 then goto ann
if keystate(49)=1 then goto cfn
loop
ann:
inc nop
input "Input ",nn$,"'s Base HP: ",hpbase(nop)
input "Input ",nn$,"'s Base Attack: ",attbase(nop)
input "Input ",nn$,"'s Base Defense: ",defbase(nop)
input "Input ",nn$,"'s Base Special Attack: ",spabase(nop)
input "Input ",nn$,"'s Base Special Defense: ",spdbase(nop)
input "Input ",nn$,"'s Base Speed: ",spebase(nop)
delete file "psdb.pbc"
open to write 1,"psdb.pbc"
write file 1,nop
for e=1 to nop
write string 1,name$(e)
write file 1,hpbase(e)
write file 1,attbase(e)
write file 1,defbase(e)
write file 1,spabase(e)
write file 1,spdbase(e)
write file 1,spebase(e)
next e
close file 1
pkn=nop
found:
pkn=w
print nn$," has been found."

Programs for programmers.