'=========================================================================== ' Subject: DIRECTORY CHANGER Date: 05-31-98 (19:52) ' Author: Anders Olofsson Code: QB, PDS ' Origin: anders.olofsson@mail.bip.net Packet: DOS.ABC '=========================================================================== ' Directory changer, by Anders Olofsson, 1998. ' ' Special thanks to: ' * Rich Geldreich - Wrote the Getdir sub. (which has been modified a little) ' * John White/Dan Bridges - Wrote the Wrapline sub. ' * Some other unknown authors ' * All basic programmers! ' ' USE: ' Compile it and move the .exe-file to C:\DOS or ' any directory in the PATH enviroment-variable. ' When you want to change directory, just type "CDS" ' at the DOS-prompt and you'll get a list with ' directories. Use the arrowkeys to select a directory ' and then press ESC. The program changes from current ' directory to the directory you have selected from the list. ' To delete a file, press DEL... DEFINT A-Z '$DYNAMIC DECLARE SUB WrapLine (Strlen%, StrIn$, ParsedLines$(), NumOfLines%) DECLARE FUNCTION FloppyDriveReady% (drive$) DECLARE FUNCTION CurrentDirectory$ (Dr$) DECLARE FUNCTION CHDRiVe% (Dr$) DECLARE SUB Sort (Arr$(), Start%, E%) DECLARE SUB Getdir (Entryname$(), EType%, FileDate%, DirNum%, Path$, Status%) DECLARE SUB Win (R1%, C1%, Wid%, Hei%, S%, WindowC%, TitleC%, ShadowC%) DECLARE FUNCTION SelectFile$ (FileType$) DECLARE FUNCTION SaveScrn$ () DECLARE FUNCTION ErrorText$ (ErrorNum%) DECLARE SUB POKES (Start%, S$) DECLARE FUNCTION PEEK$ (Start%, Length%) DECLARE SUB Msgbox (T$, Wid%, BorderC%, TextC%, WindowC%, Title$, Tcolor%, Waitkey%) DECLARE SUB Center (R%, T$) DECLARE FUNCTION Keyboard% () TYPE RegTypeX ax AS INTEGER: bx AS INTEGER: cx AS INTEGER dx AS INTEGER: bp AS INTEGER: si AS INTEGER di AS INTEGER: flags AS INTEGER: ds AS INTEGER es AS INTEGER END TYPE TYPE FileFindBuf DOS AS STRING * 21 Attributes AS STRING * 1 AccessTime AS STRING * 2 AccessDate AS STRING * 2 FileSize AS LONG filename AS STRING * 13 END TYPE CONST Rows = 25 DIM SHARED QuitScrn AS STRING, SaveRow AS INTEGER, SaveCol AS INTEGER DIM SHARED inreg AS RegTypeX, outreg AS RegTypeX DIM SHARED ScreenSegment AS INTEGER SaveRow = CSRLIN: SaveCol = POS(0) DEF SEG = &H40 A = PEEK(&H10) IF A AND 2 ^ 4 THEN ' Bit 4 will be high it's a BW card & monitor. ScreenSegment = &HB000 ELSE ScreenSegment = &HB800 END IF DEF SEG QuitScrn = SaveScrn$ ON ERROR GOTO ErrorHandler Z$ = SelectFile$("*.*") DEF SEG = ScreenSegment: POKES 0, QuitScrn: DEF SEG LOCATE SaveRow, SaveCol: PRINT END ErrorHandler: COLOR 0, 0: CLS : PALETTE Msgbox ErrorText$(ERR) + ".", 40, 12, 0, 7, "ERROR!", 10, 1 DEF SEG = ScreenSegment: POKES 0, QuitScrn: DEF SEG LOCATE SaveRow, SaveCol: PRINT END REM $STATIC SUB Center (R, T$) LOCATE R, 41 - (LEN(T$) \ 2) PRINT T$; END SUB FUNCTION CHDRiVe (Dr$) DIM regsX AS RegTypeX IF Dr$ <> "" THEN DrNumber = ASC(UCASE$(LEFT$(Dr$, 1))) - 65 IF DrNumber >= 0 AND DrNumber <= 25 THEN regsX.ax = &HE00 regsX.dx = DrNumber CALL INTERRUPTX(&H21, regsX, regsX) regsX.ax = &H1900 CALL INTERRUPTX(&H21, regsX, regsX) IF DrNumber <> (regsX.ax AND 255) THEN CHDRiVe = -1 'no such drive END IF END IF END IF END FUNCTION FUNCTION CurrentDirectory$ (Dr$) DIM regsX AS RegTypeX DIM Buffer(128) aseg = VARSEG(Buffer(0)) aptr = VARPTR(Buffer(0)) IF Dr$ = "" THEN regsX.ax = &H1900 CALL INTERRUPTX(&H21, regsX, regsX) DrCode = (regsX.ax AND 255) + 1 Dr$ = CHR$(DrCode + 64) ELSE Dr$ = UCASE$(LEFT$(Dr$, 1)) DrCode = ASC(Dr$) - 64 END IF regsX.ax = &H4700 regsX.dx = DrCode regsX.ds = aseg regsX.si = aptr CALL INTERRUPTX(&H21, regsX, regsX) IF regsX.ax = 15 THEN ERROR 68 'no such drive ELSE DEF SEG = aseg FOR A = 0 TO 128 F$ = F$ + CHR$(PEEK(aptr + A)) NEXT DEF SEG CurrentDirectory$ = Dr$ + ":\" + LEFT$(F$, INSTR(F$, CHR$(0)) - 1) END IF END FUNCTION FUNCTION ErrorText$ (ErrorNum) SELECT CASE ErrorNum CASE 1: ErrorText$ = "NEXT without FOR" CASE 2: ErrorText$ = "Syntax error" CASE 3: ErrorText$ = "RETURN without GOSUB" CASE 4: ErrorText$ = "Out of DATA" CASE 5: ErrorText$ = "Illegal function call" CASE 6: ErrorText$ = "Overflow" CASE 7: ErrorText$ = "Out of memory" CASE 8: ErrorText$ = "Label not defined" CASE 9: ErrorText$ = "Subscript out of range" CASE 10: ErrorText$ = "Duplicate definition" CASE 11: ErrorText$ = "Division by zero" CASE 12: ErrorText$ = "Illegal in direct mode" CASE 13: ErrorText$ = "Type mismatch" CASE 14: ErrorText$ = "Out of string space" CASE 16: ErrorText$ = "String formula too complex" CASE 17: ErrorText$ = "Cannot continue" CASE 18: ErrorText$ = "Function not defined" CASE 19: ErrorText$ = "No RESUME" CASE 20: ErrorText$ = "RESUME without error" CASE 24: ErrorText$ = "Device timeout" CASE 26: ErrorText$ = "Device fault" CASE 27: ErrorText$ = "Out of paper" CASE 29: ErrorText$ = "WHILE without WEND" CASE 30: ErrorText$ = "WEND without WHILE" CASE 33: ErrorText$ = "Duplicate label" CASE 35: ErrorText$ = "Subprogram not defined" CASE 37: ErrorText$ = "Argument-count mismatch" CASE 38: ErrorText$ = "Array not defined" CASE 40: ErrorText$ = "Variable required" CASE 50: ErrorText$ = "FIELD overflow" CASE 51: ErrorText$ = "Internal error" CASE 52: ErrorText$ = "Bad file name of number" CASE 53: ErrorText$ = "File not found" CASE 54: ErrorText$ = "Bad file mode" CASE 55: ErrorText$ = "File already open" CASE 56: ErrorText$ = "FIELD statement active" CASE 57: ErrorText$ = "Device I/O error" CASE 58: ErrorText$ = "File already exists" CASE 59: ErrorText$ = "Bad record length" CASE 61: ErrorText$ = "Disk full" CASE 62: ErrorText$ = "Input past end of file" CASE 63: ErrorText$ = "Bad record number" CASE 64: ErrorText$ = "Bad file name" CASE 67: ErrorText$ = "Too many files" CASE 68: ErrorText$ = "Device unavailable" CASE 69: ErrorText$ = "Communication-buffer overflow" CASE 70: ErrorText$ = "Permission denied" CASE 71: ErrorText$ = "Disk not ready" CASE 72: ErrorText$ = "Disk-media error" CASE 73: ErrorText$ = "Feature unavailable" CASE 74: ErrorText$ = "Rename across disks" CASE 75: ErrorText$ = "Path/File access error" CASE 76: ErrorText$ = "Path not found" CASE ELSE: ErrorText$ = "Number" + STR$(ERR) END SELECT: END FUNCTION FUNCTION FloppyDriveReady% (drive$) drive% = (ASC(drive$) OR 32) - 97 'reset floppy drive inreg.ax = 0 inreg.dx = drive% CALL INTERRUPTX(&H13, inreg, inreg) inreg.ax = &H401 'verify disk sector inreg.cx = &H101 inreg.dx = drive% CALL INTERRUPTX(&H13, inreg, inreg) 'call the interrupt twice since if a disk has just been 'inserted, the first time gives a wrong answer inreg.ax = &H401 inreg.cx = &H101 inreg.dx = drive% CALL INTERRUPTX(&H13, inreg, inreg) 'if it was a hard disk we just checked forget the whole thing IF inreg.ax AND 256 THEN inreg.ax = &H1C00 ' check drive type inreg.dx = drive% + 1 ' diff. drive number system must add 1 CALL INTERRUPTX(&H21, inreg, inreg) ' check if drive was a valid drive letter. IF (inreg.ax AND &HFF) = &HFF THEN HardCheck = 0 ELSE HardCheck = -1 END IF FloppyDriveReady% = ((inreg.flags AND 1) = 0) OR HardCheck END FUNCTION SUB Getdir (Entryname$(), EType, FileDate, DirNum, Path$, Status) IF EType = 1 THEN FT = 32 ELSE FT = 16 ' Entryname$() is where the file & dir names are stored ' EType: If EType = 2 then you'll get dirs in the Entryname$() else ' you'll get files. ' Filedate: Specify true if you want dates after the file & dir names in ' Entryname$(). ' DirNum: Number of items found ' Path$: Where and what to look after. (ex. "C:\*.*") ' Status: Status is true if an error has occured DirNum = 0 DIM Buffer AS FileFindBuf inreg.ax = &H1A00 inreg.ds = VARSEG(Buffer) inreg.dx = VARPTR(Buffer) CALL INTERRUPTX(&H21, inreg, inreg) inreg.ax = &H4E00 inreg.cx = 16 Npath$ = Path$ + CHR$(0) inreg.dx = SADD(Npath$) CALL INTERRUPTX(&H21, inreg, inreg) FirstFM = (inreg.ax AND &HF) IF inreg.flags AND 1 THEN Status = -1 EXIT SUB ELSE Status = 0 END IF IF FirstFM = 0 THEN GOSUB MakeFile DO inreg.ax = &H4F00 inreg.dx = SADD(Npath$) CALL INTERRUPTX(&H21, inreg, inreg) NextFM = inreg.ax AND &HF IF NextFM <> 0 THEN EXIT DO ELSE GOSUB MakeFile END IF LOOP END IF EXIT SUB MakeFile: IF (ASC(Buffer.Attributes) = FT OR FT = 32 AND ASC(Buffer.Attributes) < 16) AND LEFT$(Buffer.filename, 2) <> "." + CHR$(0) THEN Entry$ = RTRIM$(Buffer.filename) IF FileDate THEN GOSUB MakeDateTime FOR A = 1 TO LEN(Entry$) Y$ = MID$(Entry$, A, 1) IF Y$ <> CHR$(0) AND Y$ <> " " THEN Lastchar = A NEXT A Entryname$(DirNum) = LEFT$(Entry$, Lastchar) DirNum = DirNum + 1 END IF Buffer.Attributes = "" Buffer.AccessTime = "" Buffer.AccessDate = "" Buffer.FileSize = 0 Buffer.filename = SPACE$(13) RETURN MakeDateTime: Aika% = CVI(Buffer.AccessTime) sek = 0 IF (Aika% AND 1) = 1 THEN sek = sek + 1 '0 IF (Aika% AND 2) = 2 THEN sek = sek + 2 '1 IF (Aika% AND 4) = 4 THEN sek = sek + 4 '2 IF (Aika% AND 8) = 8 THEN sek = sek + 8 '3 IF (Aika% AND 16) = 16 THEN sek = sek + 16 '4 sek = sek * 2 min = 0 IF (Aika% AND 32) = 32 THEN min = min + 1 IF (Aika% AND 64) = 64 THEN min = min + 2 IF (Aika% AND 128) = 128 THEN min = min + 4 IF (Aika% AND 256) = 256 THEN min = min + 8 IF (Aika% AND 512) = 512 THEN min = min + 16 IF (Aika% AND 1024) = 1024 THEN min = min + 32 hh = 0 IF (Aika% AND 2048) = 2048 THEN hh = hh + 1 IF (Aika% AND 4096) = 4096 THEN hh = hh + 2 IF (Aika% AND 8192) = 8192 THEN hh = hh + 4 IF (Aika% AND 16384) = 16384 THEN hh = hh + 8 IF (Aika% AND 32768) = 32768 THEN hh = hh + 16 Pvm% = CVI(Buffer.AccessDate) pv = 0 IF (Pvm% AND 1) = 1 THEN pv = pv + 1 IF (Pvm% AND 2) = 2 THEN pv = pv + 2 IF (Pvm% AND 4) = 4 THEN pv = pv + 4 IF (Pvm% AND 8) = 8 THEN pv = pv + 8 IF (Pvm% AND 16) = 16 THEN pv = pv + 16 kk = 0 IF (Pvm% AND 32) = 32 THEN kk = kk + 1 IF (Pvm% AND 64) = 64 THEN kk = kk + 2 IF (Pvm% AND 128) = 128 THEN kk = kk + 4 IF (Pvm% AND 256) = 256 THEN kk = kk + 8 vv = 0 IF (Pvm% AND 512) = 512 THEN vv = vv + 1 IF (Pvm% AND 1024) = 1024 THEN vv = vv + 2 IF (Pvm% AND 2048) = 2048 THEN vv = vv + 4 IF (Pvm% AND 4096) = 4096 THEN vv = vv + 8 IF (Pvm% AND 8192) = 8192 THEN vv = vv + 16 IF (Pvm% AND 16384) = 16384 THEN vv = vv + 32 IF (Pvm% AND 32768) = 32768 THEN vv = vv + 64 vv = 1980 + vv Aika$ = STRING$(2 - LEN(LTRIM$(STR$(hh))), "0") + LTRIM$(STR$(hh)) + ":" + STRING$(2 - LEN(LTRIM$(STR$(min))), "0") + LTRIM$(STR$(min)) + "." + STRING$(2 - LEN(LTRIM$(STR$(sek))), "0") + LTRIM$(STR$(sek)) Pvm$ = STRING$(2 - LEN(LTRIM$(STR$(pv))), "0") + LTRIM$(STR$(pv)) + "/" + STRING$(2 - LEN(LTRIM$(STR$(kk))), "0") + LTRIM$(STR$(kk)) + "/" + RIGHT$(STR$(vv), 2) Tim$ = Pvm$ Dat$ = Aika$ Entry$ = Entry$ + " | " + Tim$ + " " + Dat$ RETURN END SUB FUNCTION Keyboard S$ = INKEY$ IF LEN(S$) = 1 THEN Keyboard = ASC(S$) ELSEIF LEN(S$) = 2 THEN Keyboard = -ASC(RIGHT$(S$, 1)) END IF END FUNCTION SUB Msgbox (T$, Wid, BorderC, TextC, WindowC, Title$, Tcolor, Waitkey) Savescreen$ = SaveScrn$ DIM Message(50) AS STRING WrapLine Wid - 4, T$, Message(), Lines COLOR BorderC, WindowC Center Rows \ 2 - (Lines \ 2), CHR$(218) + STRING$(Wid - 2, 196) + CHR$(191) Center Rows \ 2 - (Lines \ 2), CHR$(180) + SPACE$(LEN(Title$)) + CHR$(195) COLOR Tcolor Center Rows \ 2 - (Lines \ 2), Title$ FOR Z = 1 TO Lines COLOR BorderC, WindowC Center Rows \ 2 - (Lines \ 2) + Z, "³ " + LEFT$(SPACE$(180), Wid - 4) + " ³" COLOR TextC Center Rows \ 2 - (Lines \ 2) + Z, LEFT$(Message(Z) + SPACE$(80), Wid - 4) NEXT COLOR BorderC, WindowC Center Rows \ 2 - (Lines \ 2) + Z, CHR$(192) + STRING$(Wid - 2, 196) + CHR$(217) COLOR TextC IF Waitkey THEN DO: LOOP UNTIL LEN(INKEY$) DEF SEG = ScreenSegment: POKES 0, Savescreen$: DEF SEG END IF END SUB FUNCTION PEEK$ (Start, Length) T$ = SPACE$((Length - Start) + 1) FOR A& = Start TO Length Z& = Z& + 1 MID$(T$, Z&, 1) = CHR$(PEEK(A&)) NEXT A& SWAP PEEK$, T$ END FUNCTION SUB POKES (Start, S$) FOR A& = Start + 1 TO LEN(S$) POKE A& - 1, ASC(MID$(S$, A&, 1)) NEXT A& END SUB FUNCTION SaveScrn$ DEF SEG = ScreenSegment SaveScrn$ = PEEK$(0, 80 * Rows * 2) DEF SEG END FUNCTION FUNCTION SelectFile$ (FileType$) REDIM Files$(0), Dirs$(0) SScreen$ = SaveScrn$ Win Rows \ 2 - 8, 17, 80 - 33, 14, 1, 7, 3, 8 COLOR 3, 0: LOCATE Rows \ 2 - 8, 19: PRINT ""; COLOR 7: PRINT " Select directory: "; COLOR 0, 7 LOCATE Rows \ 2 - 6, 25: PRINT "Files" LOCATE Rows \ 2 - 6, 44: PRINT "Dirs/Drives" SelectedList = 2 GOSUB RefreshDir DO Z = Keyboard SELECT CASE Z CASE -80 IF SelectedList = 1 THEN OldF = SelectedFile SelectedFile = SelectedFile + 1 IF SelectedFile > Num.Files - 1 THEN SelectedFile = Num.Files - 1 IF SelectedFile > FileLoc + 10 THEN FileLoc = SelectedFile - 10 IF OldF <> SelectedFile THEN GOSUB RefreshList ELSE OldD = SelectedDir SelectedDir = SelectedDir + 1 IF SelectedDir > Num.Dirs - 1 THEN SelectedDir = Num.Dirs - 1 IF SelectedDir > DirLoc + 10 THEN DirLoc = SelectedDir - 10 IF OldD <> SelectedDir THEN GOSUB RefreshList END IF CASE -72 IF SelectedList = 1 THEN OldF = SelectedFile SelectedFile = SelectedFile - 1 IF SelectedFile < 0 THEN SelectedFile = 0 IF SelectedFile < FileLoc THEN FileLoc = SelectedFile IF OldF <> SelectedFile THEN GOSUB RefreshList ELSE OldD = SelectedDir SelectedDir = SelectedDir - 1 IF SelectedDir < 0 THEN SelectedDir = 0 IF SelectedDir < DirLoc THEN DirLoc = SelectedDir IF OldD <> SelectedDir THEN GOSUB RefreshList END IF CASE -79 IF SelectedList = 2 THEN DirLoc = Num.Dirs - 11: SelectedDir = Num.Dirs - 1 ELSE FileLoc = Num.Files - 11: SelectedFile = Num.Files - 1 END IF GOSUB RefreshList CASE -71 IF SelectedList = 2 THEN DirLoc = 0: SelectedDir = 0 ELSE FileLoc = 0: SelectedFile = 0 END IF GOSUB RefreshList CASE -81 IF SelectedList = 1 THEN OldF = SelectedFile SelectedFile = SelectedFile + 10 IF SelectedFile > Num.Files - 1 THEN SelectedFile = Num.Files - 1 IF SelectedFile > FileLoc + 10 THEN FileLoc = SelectedFile - 10 IF SelectedFile <> OldF THEN GOSUB RefreshList ELSE OldD = SelectedDir SelectedDir = SelectedDir + 10 IF SelectedDir > Num.Dirs - 1 THEN SelectedDir = Num.Dirs - 1 IF SelectedDir > DirLoc + 10 THEN DirLoc = SelectedDir - 10 IF OldD <> SelectedDir THEN GOSUB RefreshList END IF CASE -73 IF SelectedList = 1 THEN OldF = SelectedFile SelectedFile = SelectedFile - 10 IF SelectedFile < 0 THEN SelectedFile = 0 IF SelectedFile < FileLoc THEN FileLoc = SelectedFile IF OldF <> SelectedFile THEN GOSUB RefreshList ELSE OldD = SelectedDir SelectedDir = SelectedDir - 10 IF SelectedDir < 0 THEN SelectedDir = 0 IF SelectedDir < DirLoc THEN DirLoc = SelectedDir IF OldD <> SelectedDir THEN GOSUB RefreshList END IF CASE -77, -75, 9 SelectedList = (SelectedList AND 1) + 1 GOSUB RefreshList CASE 13 IF SelectedList = 1 AND INSTR(Files$(SelectedFile), ".") THEN Ext$ = MID$(Files$(SelectedFile), INSTR(Files$(SelectedFile), ".") + 1, 4) IF Ext$ = "EXE" OR Ext$ = "COM" OR Ext$ = "BAT" THEN DEF SEG = ScreenSegment: POKES 0, SScreen$: DEF SEG LOCATE SaveRow, SaveCol: PRINT SHELL Files$(SelectedFile) SScreen$ = SaveScrn$ QuitScrn = SScreen$ SaveRow = CSRLIN: SaveCol = POS(0) Win Rows \ 2 - 8, 17, 80 - 33, 14, 1, 7, 3, 8 COLOR 3, 0: LOCATE Rows \ 2 - 8, 19: PRINT ""; COLOR 7: PRINT " Select directory: "; COLOR 0, 7 LOCATE Rows \ 2 - 6, 25: PRINT "Files" LOCATE Rows \ 2 - 6, 44: PRINT "Dirs/Drives" SelectedList = 1 GOSUB RefreshDir END IF ELSEIF SelectedList = 2 THEN IF MID$(Dirs$(SelectedDir), 5, 1) <> ":" THEN CHDIR Dirs$(SelectedDir) ELSE T$ = CurrentDirectory$("") DO IF CHDRiVe(MID$(Dirs$(SelectedDir), 4, 1)) OR NOT FloppyDriveReady(MID$(Dirs$(SelectedDir), 4, 1)) THEN PCOPY 0, 1 Msgbox ErrorText$(71) + "! Do you want to try again? (Y/N)", 40, 2, 0, 7, "Drive error!", 10, 0 DO: Z = Keyboard: LOOP UNTIL Z IF UCASE$(CHR$(Z)) = "N" THEN Z = CHDRiVe(LEFT$(T$, 2)) EXIT DO END IF PCOPY 1, 0 ELSE EXIT DO END IF LOOP END IF GOSUB RefreshDir END IF CASE -83 IF SelectedList = 1 THEN Z$ = SaveScrn$ Msgbox "Do you want to delete " + Files$(SelectedFile) + "? (Y/N)", 50, 12, 0, 3, "Confirm", 10, 0: COLOR 7, 0 DO: A$ = UCASE$(CHR$(Keyboard)): LOOP UNTIL A$ = "Y" OR A$ = "N" DEF SEG = ScreenSegment: POKES 0, Z$: DEF SEG IF A$ = "Y" THEN KILL Files$(SelectedFile) SF = SelectedFile - 1: IF SF < 0 THEN SF = 0 FL = FileLoc: DL = DirLoc: SD = SelectedDir GOSUB RefreshDir SelectedFile = SF: SelectedDir = SD SelectedList = 1: FileLoc = FL: DirLoc = DL GOSUB RefreshList END IF END IF CASE 27 EXIT DO CASE ELSE IF SelectedList = 1 AND Z >= 0 THEN FOR T = 0 TO Num.Files IF UCASE$(LEFT$(Files$(T), 1)) = UCASE$(CHR$(Z)) THEN SelectedFile = T FileLoc = T GOSUB RefreshList EXIT FOR END IF NEXT ELSEIF Z >= 0 THEN FOR T = 0 TO Num.Dirs IF UCASE$(LEFT$(Dirs$(T), 1)) = UCASE$(CHR$(Z)) THEN SelectedDir = T DirLoc = T GOSUB RefreshList EXIT FOR END IF NEXT END IF END SELECT LOOP EXIT FUNCTION EXIT FUNCTION RefreshDir: REDIM Files$(768), Dirs$(768) CALL Getdir(Files$(), 1, 0, Num.Files, FileType$, Status) CALL Getdir(Dirs$(), 2, 0, Num.Dirs, "*.*", Status) Sort Files$(), 0, Num.Files - 1 Sort Dirs$(), 0, Num.Dirs - 1 TmpDir$ = CurrentDirectory$("") FOR A = 1 TO 26 IF CHDRiVe(CHR$(64 + A)) <> -1 THEN Dirs$(Num.Dirs) = " " + CHR$(64 + A) + ":" Num.Dirs = Num.Dirs + 1 END IF NEXT A = CHDRiVe(LEFT$(TmpDir$, 2)) IF Status THEN ERROR 76 DirLoc = 0: FileLoc = 0 SelectedDir = 0 SelectedFile = 0 RefreshList: COLOR 7, 0 DIM V AS STRING * 15 FOR R = 0 TO 10 Num = (R) + FileLoc V = LEFT$(Files$(Num), 14) LOCATE R + Rows \ 2 - 5, 20: PRINT " " + V + " "; IF Num = SelectedFile AND SelectedList <> 1 THEN COLOR 7, 0 LOCATE R + Rows \ 2 - 5, 20: PRINT " " + V + " "; ELSEIF Num = SelectedFile AND SelectedList = 1 THEN IF ScreenSegment = &HB800 THEN COLOR 7, 1 ELSE COLOR 7, 0 LOCATE R + Rows \ 2 - 5, 20: PRINT " " + V + " "; COLOR 7, 0 END IF NEXT FOR R = 0 TO 10 Num = (R) + DirLoc V = LEFT$(Dirs$(Num), 14) LOCATE R + Rows \ 2 - 5, 42: PRINT " " + V + " "; IF Num = SelectedDir AND SelectedList <> 2 THEN COLOR 7, 0 LOCATE R + Rows \ 2 - 5, 42: PRINT " " + V + " "; ELSEIF Num = SelectedDir AND SelectedList = 2 THEN IF ScreenSegment = &HB800 THEN COLOR 7, 1 ELSE COLOR 7, 0 LOCATE R + Rows \ 2 - 5, 42: PRINT " " + V + " "; COLOR 7, 0 END IF NEXT RETURN END FUNCTION SUB Sort (Arr$(), Start, E) FOR Z = Start TO E FOR Y = Start TO E IF Arr$(Z) < Arr$(Y) THEN SWAP Arr$(Z), Arr$(Y) NEXT Y NEXT Z END SUB SUB Win (R1, C1, Wid, Hei, S, WindowC, TitleC, ShadowC) COLOR WindowC, TitleC LOCATE R1, C1: PRINT SPACE$(Wid); FOR R = R1 + 1 TO R1 + Hei LOCATE R, C1 COLOR 0, WindowC PRINT SPACE$(Wid); IF S THEN COLOR ShadowC, 0 PRINT CHR$(SCREEN(CSRLIN, POS(0))); PRINT CHR$(SCREEN(CSRLIN, POS(0))); END IF NEXT R IF S THEN COLOR ShadowC, 0 FOR Z = C1 + 1 TO C1 + Wid + 1 LOCATE R1 + Hei + 1, Z: PRINT CHR$(SCREEN(CSRLIN, POS(0))); NEXT END IF END SUB SUB WrapLine (Strlen, StrIn$, ParsedLines$(), NumOfLines) IF StrIn$ = "" THEN NumOfLines = 0 EXIT SUB END IF 'If string to split is nothing, exit. Work$ = StrIn$ 'Keep original value in StrIn$ Done = False 'reset flag DO IF LEN(Work$) > Strlen THEN NumOfLines = NumOfLines + 1 'Increment index to array WorkPlus$ = LEFT$(Work$, Strlen + 1) 'WorkPlus$ is used to see if there is a space immediately 'after the requested split point so we do not split a word. FOR SearchStartPos = Strlen TO 1 STEP -1 LastSpacePos = INSTR(SearchStartPos, WorkPlus$, " ") IF LastSpacePos THEN ParsedLines$(NumOfLines) = LTRIM$(RTRIM$(LEFT$(Work$, LastSpacePos))) 'Put left (StrLen) chars in array Work$ = MID$(Work$, SearchStartPos + 1) 'Remove parsed segment from Work$ EXIT FOR END IF NEXT SearchStartPos ELSE Done = -1 END IF LOOP UNTIL Done NumOfLines = NumOfLines + 1 'Save remainder of StrIn$ ParsedLines$(NumOfLines) = LTRIM$(Work$) END SUB SUB Writestring (Y, X, S$, C) Memloc = 80 * (Y - 1) + (X - 1) Memloc = Memloc * 2 DEF SEG = ScreenSegment FOR T = 0 TO LEN(S$) - 1 POKE Memloc, ASC(MID$(S$, T + 1, 1)) POKE Memloc + 1, C Memloc = Memloc + 2 NEXT T DEF SEG END SUB