Hello Fellow Game Developers
I have just finished typing out the exercise code from the Beginner's Guide To Dark Basic book. When I go to compile the code, this line is said to be causing a syntax error: startA = (currentpage(1)*pagesize(1))+1 . If someone could go through my code and check it, that would be great.
Rem Project: DirectroyManager Program
Rem Created: Tuesday, March 13, 2012
Rem Designer: Andrew D. South
Rem ***** Main Source File *****
DIM currentselecteditem(1)
DIM currentfile$(1)
DIM currentfiletype(1)
DIM maxfiles(1)
DIM pagesize(1)
DIM newcommand(1)
DIM pagestartY(1)
DIM filespaceing(1)
newcommand(1) = 0
currentpage(1) = 0
currentselecteditem(1) = 1
maxfiles(1) = 0
pagesize(1) = 20
pagestartY(1) = 40
filespaceing(1) = 16
SYNC ON
SYNC RATE 30
SET TEXT OPAQUE
DISPLAYINFO()
DISPLAYFILES()
WHILE ESCAPEKEY() = 0
CHECKkeyMOVEMENT()
CHECKMOUSEMOVEMENTS()
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
tempstring$ = CHECKLIST STRING$(x)
ELSE
tempstring$ = "<"+CHECKLIST STRING$(x)+">"
ENDIF
IF currentselecteditem(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 , tempstring$
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) = 1
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 CHECKMOUSEMOVEMENTS()
IF MOUSECLICK() = 0 THEN EXITFUNCTION
IF MOUSEY() < pagestartY(1) THEN EXITFUNCTION
IF MOUSEY() > pagestartY(1)+(pagesize(1)*filespacing(1))
EXITFUNCTION
ENDIF
lastpage = maxfiles(1)/pagesize(1)
IF currentpage(1) = lastpage
lastitem = 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()
`New Command will be processed
`0 -- No New Command
`1 -- Get Help
`2 -- Change Drives
`3 -- Move Up
`4 -- Move Down
`5 -- Chage Dirs
`6 -- Page Up
`7 -- Page Down
`8 -- Delete Dir
`9 -- Make Dir
`Determine where the last file and page are
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
`Get the Help
IF cmdtoprocess = 1
DISPLAYHELP()
CLS
DISPLAYINFO()
DISPLAYFILES()
ENDIF
`Change Drives
IF cmdtoprocess = 2
CLS
DISPLAYINFO()
DISPLAYFILES()
ENDIF
`Move Up
IF cmdtoprocess = 3
currentselecteditem(1) = currentselecteditem(1) - 1
IF currentselecteditem(1) <= 0
currentselecteditem(1) = lastitem
ENDIF
DISPLAYFILES()
ENDIF
`Move Down
IF cmdtoprocess = 4
currentselecteditem(1) = currentselecteditem(1) + 1
IF currentselecteditem(1) > lastitem
currentselecteditem(1) = 1
ENDIF
DISPLAYFILES()
ENDIF
`Change Directories
IF cmdtoprocess = 5
newdir$ = currentfile$(1)
SET DIR newdir$
currentpage(1) = 0
CLS
DISPLAYINFO()
DISPLAYFILES()
ENDIF
`Page Up
IF cmdtoprocess = 6
currentpage(1) = currentpage(1) - 1
IF currentpage(1) < 0
currentpage(1) = 0
ENDIF
CLS
DISPLAYINFO()
DISPLAYFILES()
ENDIF
`Page Down
IF cmdtoprocess = 7
currentpage(1) = currentpage(1) + 1
IF currentpage(1) > lastpage
currentpage(1) = lastpage
ENDIF
CLS
DISPLAYINFO()
DISPLAYFILES()
ENDIF
`Delete a Directory
IF cmdtoprocess = 8
deletedir$ = currentfile$(1)
`You do not want to delete . or the .. directory ..
`Trust me on this
IF deletedir$ = "." THEN EXITFUNCTION
IF deletedir$ = ".." THEN EXITFUNCTION
tempstring$ = "Are you srue you want to delete " + Deletedir$
TEXT 10,400, tempstring$
A$ = ASKYESNO$()
IF A$ = "YES"
DELETE DIRECTORY deletedir$
ENDIF
CLS
DISPLAYINFO()
DISPLAYFILES()
ENDIF
`Create a Directory
IF cmdtoprocess = 9
SET CURSOR 10,400
INPUT "Type in the name of teh 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 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 -- DELEATE A DIRECTROY"
PRINT "INS -- CREATE A NEW DIRECTORY"
PRINT "D -- CHANGE DRIVERS"
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()<=1 THEN EXITFUNCTION
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
newdrive$ = ch$+":\"
SET DIR newdrive$
ENDFUNCTION
When we all lend our power together, there is nothing we
can't do!
Please Lend me your STRENGTH!