Hello. I noticed that DBP had a perform checklist for files command, but no perform checklist for folders! Since I needed it, I decided to make one. It uses the PERFORM CHECKLIST FOR FILES command and instead of storing files and folders it only stores folders. There are custom Checklist Quantity() and Checklist String$(item) commands here, but they work just like their DBP counterparts. I also use array stacks here so that if need be the checklist can be expanded to hold more items. The start size of the checklist (how many folders it can hold at first without expanding) is up to you and can be specified in the FolderChecklistSetup() command. Two global arrays are used to store the data.
The functions are:
FolderChecklistSetup( ChecklistSize )
This sets up the arrays needed for the folder checklist system. Be sure to call this before you use any of the folder checklist functions. The
ChecklistSize parameter is the number of items that the checklist will be able to hold without expanding. The checklist will expand if it has to though. For example, if you put a 100 here but ended up finding 500 folders, the checklist arrays would increase in size to hold those 500 folders.
PerformChecklistForFolders()
Creates the actual list of folders. It works just like the PERFORM CHECKLIST FOR FILES command. To change the checklist directory, use
SET DIR$ (just like perform checklist for files).
Return Value=
FolderChecklistQuantity()
This returns the number of folders found. It works just like the CHECKLIST QUANTITY() command.
Return String=
FolderChecklistString$(item)
This returns the folder name of one of the folders found in the checklist. The
item parameter specifies which item on the list is returned. For example, if there were 5 folders found and you want the name of the 3rd one that it found, then you would use this command and set the item number to 3. Keep in mind that specifying a number greater than the folder checklist quantity will return an empty string.
Example:
REM Project: Perform Checklist for Folders
REM Created: 6/24/2009 5:14:47 PM
REM
REM ***** Main Source File *****
REM
rem Setup some text.
set text font "Arial"
set text size 14
rem Setup the folders. Create a checklist of size 255. If you go over that, the array will automatically expand.
FolderChecklistSetup(255)
rem Call our checklist command.
PerformChecklistForFolders()
rem Get how many folders were found
cq=FolderChecklistQuantity()
rem Print how many folders were found.
print "CHECKLIST QUANTITY: ",cq
print " "
rem Print the folder names.
for f = 1 to cq
print str$(f),") ",FolderChecklistString$(f)
next f
rem Wait for a key press.
wait key
rem End the program.
END
rem Call this before using any folder checklist commands.
Function FolderChecklistSetup(checklistsize)
if checklistsize<=0 then checklistsize=255
DIM FolderChecklistItems$(checklistsize)
DIM S_FolderChecklistItems(checklistsize)
for p = 1 to checklistsize
S_FolderChecklistItems(p)=p
next p
Endfunction
rem Works just like PERFORM CHECKLIST FOR FILES, only it works on folders instead.
Function PerformChecklistForFolders()
for p = 1 to checklistsize
S_FolderChecklistItems(p)=p
next p
S_FolderChecklistItems(0)=0
PERFORM CHECKLIST FOR FILES
for l = 3 to checklist quantity()
thispath$=""
thispath$=get dir$()+"\"+checklist string$(l)
if path exist(thispath$) and file exist(thispath$)=0
slot=GetFreeFolderChecklistItemSlot()
FolderChecklistItems$(slot)=checklist string$(l)
endif
next l
Endfunction
rem Works just like CHECKLIST QUANTITY()
Function FolderChecklistQuantity()
Temp=S_FolderChecklistItems(0)
Endfunction Temp
rem Works just like CHECKLIST STRING$
Function FolderChecklistString$(item)
if item>S_FolderChecklistItems(0) then exitfunction ""
Temp$=FolderChecklistItems$( S_FolderChecklistItems(item) )
Endfunction Temp$
Rem **************************************************************************************************
Rem
Rem ***** ARRAY STACK SYSTEM TO HANDLE ALMOST UNLIMITED NUMBERS OF FOLDERS WITHOUT MEMORY LEAKS. *****
Rem
Rem **************************************************************************************************
Function GetFreeFolderChecklistItemSlot()
rem Slot 0 stores the highest allocated slot in the S_FolderChecklistItems array.
inc S_FolderChecklistItems(0),1
rem If need be, increase the size of the array.
if S_FolderChecklistItems(0)>ARRAY COUNT(S_FolderChecklistItems())
AC=array Count(S_FolderChecklistItems())
Add=INT(AC*1.0*0.10)
if Add<1 then Add=1
DIM S_FolderChecklistItems(AC+ADD)
DIM FolderChecklistItems$(AC+ADD)
for s = AC+1 to AC+Add
S_FolderChecklistItems(s)=s
next s
endif
slot=S_FolderChecklistItems(0)
freeslot=S_FolderChecklistItems(slot)
Endfunction freeslot
Functions alone:
rem Call this before using any folder checklist commands.
Function FolderChecklistSetup(checklistsize)
if checklistsize<=0 then checklistsize=255
DIM FolderChecklistItems$(checklistsize)
DIM S_FolderChecklistItems(checklistsize)
for p = 1 to checklistsize
S_FolderChecklistItems(p)=p
next p
Endfunction
rem Works just like PERFORM CHECKLIST FOR FILES, only it works on folders instead.
Function PerformChecklistForFolders()
for p = 1 to checklistsize
S_FolderChecklistItems(p)=p
next p
S_FolderChecklistItems(0)=0
PERFORM CHECKLIST FOR FILES
for l = 3 to checklist quantity()
thispath$=""
thispath$=get dir$()+"\"+checklist string$(l)
if path exist(thispath$) and file exist(thispath$)=0
slot=GetFreeFolderChecklistItemSlot()
FolderChecklistItems$(slot)=checklist string$(l)
endif
next l
Endfunction
rem Works just like CHECKLIST QUANTITY()
Function FolderChecklistQuantity()
Temp=S_FolderChecklistItems(0)
Endfunction Temp
rem Works just like CHECKLIST STRING$
Function FolderChecklistString$(item)
if item>S_FolderChecklistItems(0) then exitfunction ""
Temp$=FolderChecklistItems$( S_FolderChecklistItems(item) )
Endfunction Temp$
Rem **************************************************************************************************
Rem
Rem ***** ARRAY STACK SYSTEM TO HANDLE ALMOST UNLIMITED NUMBERS OF FOLDERS WITHOUT MEMORY LEAKS. *****
Rem
Rem **************************************************************************************************
Function GetFreeFolderChecklistItemSlot()
rem Slot 0 stores the highest allocated slot in the S_FolderChecklistItems array.
inc S_FolderChecklistItems(0),1
rem If need be, increase the size of the array.
if S_FolderChecklistItems(0)>ARRAY COUNT(S_FolderChecklistItems())
AC=array Count(S_FolderChecklistItems())
Add=INT(AC*1.0*0.10)
if Add<1 then Add=1
DIM S_FolderChecklistItems(AC+ADD)
DIM FolderChecklistItems$(AC+ADD)
for s = AC+1 to AC+Add
S_FolderChecklistItems(s)=s
next s
endif
slot=S_FolderChecklistItems(0)
freeslot=S_FolderChecklistItems(slot)
Endfunction freeslot
<-- Spell based team dueling game!