I'm reading the begnners guide to darkBasic game programming and I'm on chapter 15. One of the projects in the chapter is to create a file manager program. I copied the code and corrected all my mistakes but I can't figure out why its giving me this error:
Syntax Error. Nesting Error at line 318 at line 318
DIM CurrentSelectedItem(1)
DIM CurrentFile$(1)
DIM CurrentFileType(1)
DIM currentPage(1)
DIM MaxFiles(1)
DIM PageSize(1)
DIM NewCommand(1)
DIM PageStartY(1)
DIM FileSpacing(1)
NewCommand(1) = 0
CurrentPage(1) = 0
CurrentSelectedItem(1) = 1
MaxFiles(1) = 0
PageSize(1) = 20
PageStartY(1) = 40
FileSpacing(1) = 16
SYNC ON
SYNC RATE 30
SET TEXT OPAQUE
DisplayInfo()
DisplayFiles()
WHILE ESCAPEKEY() = 0
CheckKeyMovement()
CheckMouseMovement()
ProcessCommands()
SYNC
ENDWHILE
END
FUNCTION DisplayFiles()
Black = RGB(0,0,0)
White = RGB(255,255,255)
Blue = RGB(0,0,255)
PERFORM CHECKLIST FOR FILES
IF CHECKLIST QUANTITY() = 0 THEN EXITFUNCTION
MaxFiles(1) = CHECKLIST QUANTITY()
StartA = (CurrentPage(1)*PageSize(1))+1
StartB = ((CurrentPage(1)+1)*PageSize(1))
if startB > MaxFiles(1) THEN StartB = MaxFiles(1)
FOR x = StartA TO StartB
PosY = ((x-StartA)*FileSpacing(1))+PageStartY(1)
IF CHECKLIST VALUE A(X) = 0
TempSting$ = CHECKLIST STRING$(x)
ELSE
TempSting$ = "<"+CHECKLIST STRING$(x)+">"
ENDIF
IF CurrentSelectedIten(1)=(x-StartA)+1
INK White,Blue
CurrentFile$(1) = CHECKLIST STRING$(X)
CurrentFileType(1) = CHECKLIST VALUE A(X)
ELSE
INK White,Black
ENDIF
TEXT 10, PosY, TempSting$
NEXT X
ENDFUNCTION
FUNCTION CheckKeyMovement()
IF INKEY$() = "?"
WHILE INKEY$()="?"
SYNC
ENDWHILE
NewCommand(1) = 1
ENDIF
IF UPPER$(INKEY$())="D"
WHILE UPPER$(INKEY$()) = "D"
SYNC
ENDWHILE
NewCommand(1) = 2
ENDIF
IF UPKEY() = 1
WHILE UPKEY() = 1
SYNC
ENDWHILE
NewCommand(1) = 3
ENDIF
IF DOWNKEY()=1
WHILE DOWNKEY()=1
SYNC
ENDWHILE
NewCommand(1) = 4
ENDIF
IF RETURNKEY()=1 and CurrentFileType(1)<>0
WHILE RETURNKEY()=1
SYNC
ENDWHILE
NewCommand(1) = 5
ENDIF
IF KEYSTATE(201) = 1
WHILE KEYSTATE(201) = 1
SYNC
ENDWHILE
NewCommand(1) = 6
ENDIF
IF KEYSTATE(209) = 1
WHILE KEYSTATE(209)
SYNC
ENDWHILE
NewCommand(1) = 7
ENDIF
IF KEYSTATE(211) = 1 and CurrentFileType(1)<>0
WHILE KEYSTATE(211) = 1
SYNC
ENDWHILE
NewCommand(1) = 8
ENDIF
IF KEYSTATE(210) = 1
WHILE KEYSTATE(210) = 1
SYNC
ENDWHILE
NewCommand(1) = 9
ENDIF
ENDFUNCTION
FUNCTION CheckMouseMovement()
IF MOUSECLICK() = 0 THEN EXITFUNCTION
IF MOUSEY() < PageStartY(1) THEN EXITFUNCTION
IF MOUSEX() < PageStartX(1)+(PageSize(1)*FileSpacing(1))
EXITFUNCTION
ENDIF
LastPage = MaxFiles(1)/PageSize(1)
IF CurrentPage(1) = LastPage
LastIten = MaxFiles(1) - (LastPage*PageSize(1))
ELSE
LastItem = PageSize(1)
ENDIF
CurrentSelectedItem(1) = ((MouseY()-PageStartY(1))/FileSpacing(1))+1
IF CurrentSelectedItem(1) >= LastItem
CurrentSelectedItem(1) = LastItem
DisplayFiles()
ENDIF
DisplayFiles()
ENDFUNCTION
FUNCTION ProcessCommands()
LastPage = MaxFiles(1)/PageSize(1)
IF CurrentPage(1) = LastPage
LastItem = MaxFiles(1) - (LastPage*PageSize(1))
ELSE
LastItem = PageSize(1)
ENDIF
IF CurrentSelectedItem(1) >= LastItem
CurrentSelectedItem(1) = LastItem
DisplayFiles()
ENDIF
IF NewCommand(1) = 0 THEN EXITFUNCTION
CmdToProcess = NewCommand(1)
NewCommand(1) = 0
IF CmdToProcess = 1
DisplayHelp()
CLS
DisplayInfo()
DisplayFiles()
ENDIF
IF CmdToProcess = 2
ChangeDrive()
CLS
DisplayInfo()
DisplayFiles()
ENDIF
IF CmdToProcess = 3
CurrentSelectedItem(1) = CurrentSelectedItem(1) - 1
IF CurrentSelectedItem(1) <= 0
CurrentSelectedItem(1) = LastItem
ENDIF
DisplayFiles()
ENDIF
IF CmdToProcess = 4
CurrentSelectedItem(1) = CurrentSelectedItem(1) + 1
IF CurrentSelectedItem(1) > LastItem
CurrentSelectedItem(1) = 1
ENDIF
DisplayFiles()
ENDIF
IF CmdToProcess = 5
NewDir$ = CurrentFile$(1)
SET DIR NewDis$
CurrentPage(1) = 0
CLS
DisplayInfo()
DisplayFiles()
ENDIF
IF CmdToProcess = 6
CurrentPage(1) = CurrentPage(1) - 1
IF CurrentPage(1) < 0
CurrentPage(1) = 0
ENDIF
CLS
DisplayInfo()
DisplayFiles()
ENDIF
IF CmdToProcess = 7
CurrentPage(1) = CurrentPage(1) + 1
IF CurrentPage(1) > LastPage
CurrentPage(1) = LastPage
ENDIF
CLS
DisplayInfo()
DisplayFiles()
ENDIF
IF CmdToProcess = 8
DeleteDir$ = CurrentFile$(1)
IF DeleteDir$ = "." THEN EXITFUNCTION
IF DeleteDir$ = ".." THEN EXITFUNCTION
TempString$ = "Are you sure you want to delete " + DeleteDir$
TEXT 10,400,TempString$
A$ = AskYesNo$()
IF A$ = "YES"
DELETE DIRECTORY DeleteDir$
ENDIF
CLS
DisplayInfo()
DisplayFiles()
ENDIF
IF CmdToProcess = 9
SET CURSOR 10,400
INPUT "Type in the name of the Directory: ",newdir$
MAKE DIRECTORY newdir$
CLS
DisplayInfo()
DisplayFiles()
ENDIF
ENDFUNCTION
FUNCTION DisplayInfo()
Red = RGB(255,0,0)
White = RGB(255,255,255)
Black = RGB(0,0,0)
Blue = RGB(0,0,255)
INK White, Red
TEXT 320,8, "Directory Manager"
TempString$ = GET DIR$()
INK White, Black
TEXT 10,24,TempString$
INK White,Blue
TEXT 10,440," ? for help"
TEXT 10,460," ESC KEY to quit."
ENDFUNCTION
FUNCTION DisplayHelp()
CLS
PRINT "This is the directory manager Program for chapter 15"
PRINT "UP ARROW --Move up"
PRINT "DOWN ARROW --Move Down"
PRINT "PAGE UP --Page up the file list"
PRINT "PAGE DOWN --Page down the file list"
PRINT "DELETE --Delete a Directory"
PRINT "INS --Create a new Directory"
PRINT "D --Change Drives"
CENTER TEXT 320,400,"Press Q to Leave This Menu"
WHILE UPPER$(INKEY$())<>"Q"
SYNC
ENDWHILE
WHILE UPPER$(INKEY$())="Q"
SYNC
ENDWHILE
ENDFUNCTION
FUNCTION AskYesNo$()
ch$ = UPPER$(INKEY$())
WHILE ch$ <> "Y" AND ch$ <> "N"
ch$ = UPPER$(INKEY$())
SYNC
ENDWHILE
IF ch$ = "Y" THEN Ret$ = "YES"
IF ch$ = "N" THEN Ret$ = "NO"
WHILE ch$ = "Y" OR ch$ = "N"
ch$ = UPPER$(INKEY$())
SYNC
ENDWHILE
ENDFUNCTION Ret$
FUNCTION ChangeDrive()
White = RGB(255,255,255)
Black = RGB(0,0,0)
INK White,Black
PERFORM CHECKLIST FOR DRIVES
IF CHECKLIST QUANTITY()
TempString$ = "Select Drive Letter: "
FOR x=1 TO CHECKLIST QUANTITY()
TempString$ = TempString$ + CHECKLIST STRING$(X)+" "
NEXT X
Done = 0
TEXT 10,400,TempString$
SYNC
SYNC
WHILE Done = 0
ch$ = UPPER$(INKEY$())
FOR x=1 TO CHECKLIST QUANTITY()
IF ch$ = LEFT$(CHECKLIST STRING$(X),1)
Done = 1
ENDIF
NEXT X
SYNC
ENDWHILE
WHILE INKEY$()<>""
SYNC
ENDWHILE
newdrive$ = ch$+":\"
SET DIR newdrive$
ENDFUNCTION
Theres no line 318 theres only 313 lines of code... 0.o Anyone?