Jippi! i made this "C: Explorer thing" that i will use for importing stuff in my program. It works pretty good i think :)
Maybe not the best but it works :)
Press Enter To Open a Folder or File
Press Backspace To 'Go Back'
Scroll List By Pressing Up or Down Cursor
; Title AppTitle "Cermit Explorer" Const screen_x = 640, screen_y = 480, bit = 16, mode = 2 ; Graphics Graphics screen_x, screen_y, bit, mode SetBuffer BackBuffer() ; Import Type Type import Field import_nr, import_name$ End Type ; Globals Global current_dir$ = "C:";Games";CurrentDir$ Global first_s = 3 ; First Slash In Current_Dir$ String Global lasta_s = 3 ; Last Slash In Current_Dir$ String Global list_y = 0 ; List Top In Current_Dir$ Global list_select = 5 ; Selected File In Current_Dir$ Global list_nr = 0 ; Number Of Files In Current_Dir$ Gosub get_file ; Read Current Dir ; The Code Is Obvious If You Understand What The Variables Are For :) ; Main Program While KeyHit(1) = False ; Move List If KeyHit(200) Then list_select = list_select - 1 list_y = list_select - 5 If list_select < 0 Then list_select = 0 If list_y > list_nr - 10 Then list_y = list_nr - 10 If list_y < 0 Then list_y = 0 EndIf If KeyHit(208) Then list_select = list_select + 1 list_y = list_select - 5 If list_select > list_nr - 1 Then list_select = list_nr - 1 If list_y > list_nr - 10 Then list_y = list_nr - 10 If list_y < 0 Then list_y = 0 EndIf ; Sub Dir If KeyHit(28) Then For i.import = Each import If i\import_nr = list_select Then ; If Dir If FileType(current_dir$ + i\import_name$) = 2 Then current_dir$ = current_dir$ + i\import_name$ + "" Gosub get_file list_select = 2 list_y = 0 Exit EndIf ; If File If FileType(current_dir$ + i\import_name$) = 1 Then ExecFile(current_dir$ + i\import_name$) Exit EndIf EndIf Next EndIf ; Above Dir If KeyHit(14) Then list_select = 2 list_y = 0 For x = 1 To Len(current_dir$) If Mid$( current_dir$, x, 1 ) = "" Then first_s = lasta_s : lasta_s = x Next current_dir$ = Left$( current_dir$, first_s ) Gosub get_file EndIf ; Clear Screen Cls ; Draw Import For i.import = Each import For y = 0 To 9 If i\import_nr => y + list_y And i\import_nr <= list_y + 9 If list_select = i\import_nr Then Color 255, 0, 0 Rect (screen_x / 2) - ((Len( i\import_name) / 2 * 10)), 16 + (i\import_nr - list_y) * 12, Len( i\import_name$ ) * 10, 12, 1 EndIf Color 0, 255, 0 Text screen_x / 2, 16 + (i\import_nr - list_y) * 12, i\import_name$, 1 EndIf Next Next ; Current Dir Text screen_x / 2, screen_y / 2, current_dir$, 1 ; Flip Flip ; Program End Wend End ; Get Import List .get_file For i.import = Each import : Delete i : Next dir = ReadDir( current_dir$ ) list_nr = 0 .read_again file$ = NextFile$( dir ) If Len(file$) > 0 Then i.import = New import i\import_nr = list_nr i\import_name$ = file$ list_nr = list_nr + 1 Goto read_again EndIf Return
Maybe not the best but it works :)
Press Enter To Open a Folder or File
Press Backspace To 'Go Back'
Scroll List By Pressing Up or Down Cursor