yes i know it is kinda usless but the main reason i decided to do it is to learn functions a bit better.
i finished the whole thing like 2 hours ago and here si the whole thing it is 326 lines o fcode.
rem --------------------------
rem march 20th 2006
rem directory manager program
rem --------------------------
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
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 , TempStrin$
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) = 7
endif
if 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 CheckMouseMovement()
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()
rem new command list... if NEWCOMMAND equals these values the new command will be processed. :p
rem 0 -- no new commands
rem 1 -- get help
rem 2 -- change drives
rem 3 -- move up
rem 4 -- move down
rem 5 -- change directorys
rem 6 -- page up
rem 7 -- page down
rem 8 -- delete directory
rem 9 -- make directory
rem determine were 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
rem get the help
if CmdToProcess = 1
DisplayHelp()
CLS
DisplayInfo()
DisplayFiles()
endif
rem change drives
if CmdToProcess = 2
ChangeDrive()
CLS
DisplayInfo()
DisplayFiles()
endif
rem move up
if CmdToProcess = 3
CurrentSelectedItem(1) = CurrentSelectedItem(1) - 1
if CurrentSelectedItem(1) <= 0
CurrentSelectedItem(1) = LastItem
endif
DisplayFiles()
endif
rem move down
if CmdToProcess = 4
CurrentSelectedItem(1) = CurrentSelectedItem(1) + 1
if CurrentSelectedItem(1) > LastItem
CurrentSelectedItem(1) = 1
endif
DisplayFiles()
endif
rem change directorys
if CmdToProcess = 5
NewDir$ = CurrentFile$(1)
set dir NewDir$
CurrentPage(1) = 0
CLS
DisplayInfo()
DisplayFiles()
endif
rem page up
if CmdToProcess = 6
CurrentPage(1) = CurrentPage(1) - 1
if CurrentPage(1) < 0
CurrentPage(1) = 0
endif
CLS
DisplayInfo()
DisplayFiles()
endif
rem page down -- change pages
if CmdToProcess = 7
CurrentPage(1) = CurrentPage(1) + 1
if CurrentPage(1) > LastPage
CurrentPage(1) = LastPage
endif
CLS
DisplayInfo()
DisplayFiles()
endif
rem delete a directory
if CmdToProcess = 8
DeleteDir$ = CurrentFile$(1)
rem you dont want to delete.. the directory
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
rem create a directory
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$ = GetDir$()
ink white,black
text 10,24,TempStrin$
ink white,blue
text 10,440,"Press ? for HELP"
text 10,460," Press ESC key to quit."
endfunction
function DisplayHelp()
CLS
Print "This is the Directory Manager program"
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()<=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
while INKEY$()<>""
sync
endwhile
newdrive$ = ch$+":\"
set dir newdrive$
endfunction
visit my site (unfinished)
www.freewebs.com/dbnewbie