I'm writing kind of a simple word processor to refresh my skills since I havn't worked with DBP in awhile, and I'm having a problem when I save strings to a file...Basicly, lines 1-19 are being saved, and then 20-26 are blank. Code below and .exe attached.
global line1$
global line2$
global line3$
global line4$
global line5$
global line6$
global line7$
global line8$
global line9$
global line10$
global line11$
global line12$
global line13$
global line14$
global line15$
global line16$
global line17$
global line18$
global line19$
global line020$
global line021$
global line022$
global line023$
global line024$
global line025$
global line026$
main:
do
cls
print "O New Document"
set cursor 0,15
print "O Load Document"
Mx=MouseX(): My=MouseY(): Mc=MouseClick()
If Mc=1 Then Gosub CheckRegion1
Sync
Loop
checkregion1:
`First Button
If Mx > 0 and My > 0 And My < 15 then Writer()
`Second Button
If Mx > 0 and My > 15 And My < 30
gosub loadmenu
Endif
function SaveDoc()
if file exist("Doc01.txt")
if file exist("Doc02.txt")
if file exist("Doc03.txt")
print "Please delete a document to Save..."
wait key
gosub main
endif
open to write 1,"Doc03.txt"
gosub writetofile
endif
open to write 1,"Doc02.txt"
gosub writetofile
endif
open to write 1,"Doc01.txt"
gosub writetofile
writetofile:
write string 1, title$
write string 1, line1$
write string 1, line2$
write string 1, line3$
write string 1, line4$
write string 1, line5$
write string 1, line6$
write string 1, line7$
write string 1, line8$
write string 1, line9$
write string 1, line10$
write string 1, line11$
write string 1, line12$
write string 1, line13$
write string 1, line14$
write string 1, line15$
write string 1, line16$
write string 1, line17$
write string 1, line18$
write string 1, line19$
write string 1, line020$
write string 1, line021$
write string 1, line022$
write string 1, line023$
write string 1, line024$
write string 1, line025$
write string 1, line026$
close file 1
cls
print "Save Complete"
wait key
gosub main
endfunction
loadmenu:
cls
print "Which Slot? 1, 2, or 3?"
input "Slot:", IS1$
if IS1$="1" then LoadDoc01()
if IS1$="2" then LoadDoc02()
if IS1$="3" then loadDoc03()
function LoadDoc01()
open to read 1,"Doc01.txt"
read string 1, line1$
read string 1, line2$
read string 1, line3$
read string 1, line4$
read string 1, line5$
read string 1, line6$
read string 1, line7$
read string 1, line8$
read string 1, line9$
read string 1, line10$
read string 1, line11$
read string 1, line12$
read string 1, line13$
read string 1, line14$
read string 1, line15$
read string 1, line16$
read string 1, line17$
read string 1, line18$
read string 1, line19$
read string 1, line020$
read string 1, line021$
read string 1, line022$
read string 1, line023$
read string 1, line024$
read string 1, line025$
read string 1, line026$
close file 1
reader()
endfunction
function LoadDoc02()
open to read 1,"Doc02.txt"
read string 1, line1$
read string 1, line2$
read string 1, line3$
read string 1, line4$
read string 1, line5$
read string 1, line6$
read string 1, line7$
read string 1, line8$
read string 1, line9$
read string 1, line10$
read string 1, line11$
read string 1, line12$
read string 1, line13$
read string 1, line14$
read string 1, line15$
read string 1, line16$
read string 1, line17$
read string 1, line18$
read string 1, line19$
read string 1, line020$
read string 1, line021$
read string 1, line022$
read string 1, line023$
read string 1, line024$
read string 1, line025$
read string 1, line026$
close file 1
reader()
endfunction
function LoadDoc03()
open to read 1,"Doc03.txt"
read string 1, line1$
read string 1, line2$
read string 1, line3$
read string 1, line4$
read string 1, line5$
read string 1, line6$
read string 1, line7$
read string 1, line8$
read string 1, line9$
read string 1, line10$
read string 1, line11$
read string 1, line12$
read string 1, line13$
read string 1, line14$
read string 1, line15$
read string 1, line16$
read string 1, line17$
read string 1, line18$
read string 1, line19$
read string 1, line020$
read string 1, line021$
read string 1, line022$
read string 1, line023$
read string 1, line024$
read string 1, line025$
read string 1, line026$
close file 1
reader()
endfunction
function writer()
cls
input "Title:", title$
input "1:", line1$
input "2:", line2$
input "3:", line3$
input "4:", line4$
input "5:", line5$
input "6:", line6$
input "7:", line7$
input "8:", line8$
input "9:", line9$
input "10:", line10$
input "11:", line11$
input "12:", line12$
input "13:", line13$
input "14:", line14$
input "15:", line15$
input "16:", line16$
input "17:", line17$
input "18:", line18$
input "19:", line19$
input "20:", input020$
input "21:", input021$
input "22:", input022$
input "23:", input023$
input "24:", input024$
input "25:", input025$
input "26:", input026$
print "The End..."
wait key
re:
print "Would you like to save?"
print "1 to Save, 2 to Go to the Main Menu"
input "", IS2$
if IS2$="1" then SaveDoc()
if IS2$="2" then gosub Main
gosub re
endfunction
function reader()
cls
print "", title$
print "", line1$
print "", line2$
print "", line3$
print "", line4$
print "", line5$
print "", line6$
print "", line7$
print "", line8$
print "", line9$
print "", line10$
print "", line11$
print "", line12$
print "", line13$
print "", line14$
print "", line15$
print "", line16$
print "", line17$
print "", line18$
print "", line19$
print "", line020$
print "", line021$
print "", line022$
print "", line023$
print "", line024$
print "", line025$
print "", line026$
print ""
print "Press a key to exit"
wait key
gosub Main
endfunction
AMPConcepts.webs.com