function ShowMenu(Mode$)
while path exist("Scripts") = 0
set dir ".."
endwhile
set dir "Scripts"
perform checklist for files
dim name$(256)
rem prompt for input
while 1
j = 0
for i=1 to checklist quantity()
if left$(checklist string$(i), 4) = "Map_"
name$(j+1) = remove$(remove$(checklist string$(i), ".txt"), "Map_")
text 200, 100+ j*12, str$(j+1) + ": " + name$(j+1)
inc j
endif
next i
if Mode$ = "Save" then text 400, 200, "Enter level name:"
if Mode$ = "Load" then text 400, 200, "Enter level number:"
if inkey$() <> ""
if Toggle = 1 or prevInkey$ <> inkey$()
temp$ = temp$ + inkey$()
prevInkey$ = inkey$()
Toggle = 0
endif
else
Toggle = 1
endif
if keystate(14) = 1
if Toggle2 = 1
temp$ = remove$(temp$, right$(temp$, 2))
Toggle2 = 0
endif
else
Toggle2 = 1
endif
text 400, 220, temp$
text 400, 300, error$
if returnkey()
temp$ = remove$(temp$, cr$())
if len(temp$) = 0 then exit
if Mode$ = "Save"
SaveLevel(temp$)
if Selected > 5 then ghost object off Selected
Selected = 2
exit
endif
if Mode$ = "Load" and len(temp$) > 0
for i=1 to 1000
if ObjectList(i).Index > 0
delete object ObjectList(i).Index
ObjectList(i).Index = 0
endif
PreviewList(i) = 0
next i
num = val(temp$)
if file exist("Map_" + name$(num) + ".txt")
CurrentLevel = name$(num)
RunScript("Map_" + name$(num), 0)
RunScript("ObjectList", 0)
if Selected > 5 and object exist(Selected) then ghost object off Selected
Selected = 2
exit
else
error$ = "File number invalid!"
endif
endif
endif
sync
endwhile
endfunction
What a mess.