The best way to do that would be to scan the folder for save files using the command
perform checklist for files. You then have to loop through all of the files found and see which ones are save files. Pick those out and display them in a list on the screen for the user to click on. Here's a small example off the top of my head.
rem setup screen
sync on
sync rate 60
backdrop on
color backdrop 0
rem initialise my awesome comet box
InitAwesomeCometBox()
rem let's say you have your save files in the folder "save"
rem your savefiles have an extension called ".rofl"
rem offsetx and offsety tell the function where to draw the list of files
file$ = FindGameFile( "save" , ".rofl" , 10 , 50 )
rem no file was found
if file$ = ""
repeat
center text 512,300,"No save files found!"
sync
until scancode()
end
endif
rem a file was found
repeat
center text 512,300,"You selected the file " + file$
sync
until scancode()
end
function FindGameFile( folder$ , extension$ , offsetx , offsety )
rem local variables
local n as integer
local count as integer
local width as integer
local lastdir$ as string
rem store our last directory so we don't lose it
lastdir$ = get dir$()
rem scan folder for files
set dir folder$
perform checklist for files
rem the file selection loop
do
rem reset count. This counts how many save files were found
count = 0
rem loop through files found (3 to skip "..")
for n = 3 to checklist quantity()
rem get file name and check if it's a valid save file
file$ = checklist string$(n)
if right$(file$,len(extension$)) = extension$
rem check if mouse is currently over the file
if mousex() > offsetx and mousex() < text width(file$)+offsetx and mousey() > offsety + (count*15) and mousey() < offsety + (count*15) + 15
rem list on screen with red colour to show it's selected
ink 0xFFFF0000 , 0
text offsetx , offsety + (count*15) , file$
rem if mouse is clicked, return file
if mouseclick()
set dir lastdir$
exitfunction file$
endif
rem if mouse is not over file, just display with white
else
rem display file with white
ink 0xFFFFFFFF , 0
text offsetx , offsety + (count*15) , file$
endif
endif
rem increment counter
inc count
rem maximum text width
if width<text width(file$) then width = text width(file$)
next n
rem if no file was found, exit with an empty string
if count = 0
set dir lastdir$
exitfunction ""
endif
AwesomeCometBox(offsetx-5,offsety-10,offsetx+width+5,offsety+(count*15)+10)
rem refresh screen
sync
rem end of selection loop
loop
endfunction file$
function InitAwesomeCometBox()
global AWC_r as byte = 255
global AWC_g as byte = 0
global AWC_b as byte = 0
endfunction
function AwesomeCometBox( sx , sy , ex , ey )
rem local variables
local r as byte
local g as byte
local b as byte
rem rotate global colour
newcolor = rotcolor( AWC_r , AWC_g , AWC_b , 5 )
AWC_r = rgbr(newcolor)
AWC_g = rgbg(newcolor)
AWC_b = rgbb(newcolor)
rem draw top line
for n = sx to ex
a2dot n,sy,newcolor
newcolor = rotcolor( rgbr(newcolor) , rgbg(newcolor) , rgbb(newcolor) , 5 )
next n
rem draw right line
for n = sy to ey
a2dot ex,n,newcolor
newcolor = rotcolor( rgbr(newcolor) , rgbg(newcolor) , rgbb(newcolor) , 5 )
next n
rem draw bottom line
for n = sx to ex
a2dot n,ey,newcolor
newcolor = rotcolor( rgbr(newcolor) , rgbg(newcolor) , rgbb(newcolor) , 5 )
next n
rem draw left line
for n = sy to ey
a2dot sx,n,newcolor
newcolor = rotcolor( rgbr(newcolor) , rgbg(newcolor) , rgbb(newcolor) , 5 )
next n
endfunction
function rotcolor( r as integer , g as integer , b as integer ,stp )
if r=255 and g<255 and b=0 then inc g,stp:if g>255 then g=255
if r>0 and g=255 and b=0 then dec r,stp:if r<0 then r=0
if r=0 and g=255 and b<255 then inc b,stp:if b>255 then b=255
if r=0 and g>0 and b=255 then dec g,stp:if g<0 then g=0
if r<255 and g=0 and b=255 then inc r,stp:if r>255 then r=255
if r=255 and g=0 and b>0 then dec b,stp:if b<0 then b=0
color = 0xFF000000 || rgb(r,g,b)
endfunction color
TheComet