BBS: Inland Empire Archive Date: 01-09-93 (11:30) Number: 264 From: JOHN GALLAS Refer#: NONE To: ALL Recvd: NO Subj: FAST DIRECTORY CHANGE 1/2 Conf: (2) Quik_Bas
This program is similar to the famous NCD. Enter /SCAN on the command line and it'll scan all the directories. Anything else, and it searches for the directory in its database. I compared it speedwise to one of the shareware fast directory changers, and it was faster in finding the directory, but the scanning part is slower. If you wanted to, you could probably change this to a tree program.. Welp, here it is: '-----------------------Decapitate Here------------------------- ' JD.BAS - Fast Directory Changer - By John Gallas - 12/30/92 ' Use it as you wish, just don't forget who really wrote it. DEFINT A-Z DECLARE SUB AddDirs (CurrentDir$, ListOfEm$) DECLARE SUB ScanDrive () DECLARE FUNCTION CurDir$ () DECLARE FUNCTION DIR$ (FileSpec$) ' $INCLUDE: '\QB45\QB.BI' CONST DOS = &H21 CONST SetDTA = &H1A00, FindFirst = &H4E00, FindNext = &H4F00 CONST True = -1, False = 0 IF COMMAND$ = "" THEN PRINT PRINT "JD 1.0 By John Gallas" PRINT PRINT "Usage: JD <full or partial directory name>" PRINT " or: JD /SCAN to create a new directory database." END END IF IF INSTR(COMMAND$, "/SCAN") THEN 'they wanna scan the drive ScanDrive END END IF 'open the file OPEN "\JD.IDX" FOR BINARY AS #1 'create a string to hold its contents DirList$ = STRING$(LOF(1), 0) 'read in the string GET #1, , DirList$ 'close the file CLOSE #1 Search$ = RTRIM$(LTRIM$(COMMAND$)) 'We have to start scanning the list of directories after the current 'directoriy's entry, incase theres another dir with the same pattern. Temp$ = "C:\" + CurDir$ Check = INSTR(DirList$, Temp$ + CHR$(0)) Pointer = 1 IF Check THEN Pointer = Check + LEN(Temp$) + 5 IF INSTR(Temp$, Search$) = 0 THEN 'the current directory is definatly not one of the possible choices, so 'set the pointer back to 1. Pointer = 1 END IF Times = 1 Success = False DO Check = INSTR(Pointer, DirList$, Search$) IF Check = 0 THEN 'check if its in an earlier entry IF Times = 2 THEN Success = False: EXIT DO Pointer = 1: Times = 2 ELSE Success = True EXIT DO END IF LOOP IF Success THEN 'find the entry closest to Check FOR x = Check TO 1 STEP -1 x$ = MID$(DirList$, x, 1) IF x$ = CHR$(0) THEN x = x + 1: EXIT FOR IF x = 1 THEN EXIT FOR NEXT x x2 = INSTR(x, DirList$, CHR$(0)) ToGo$ = MID$(DirList$, x, x2 - x) CHDIR ToGo$ ELSE PRINT "Directory not found!" END IF END SUB AddDirs (CurrentDir$, ListOfEm$) Temp$ = CurrentDir$ 'Do this for the 1 exception that we're scanning C:\, because we won't get 'any files when we ask for a list in C:\\*.* IF RIGHT$(Temp$, 1) = "\" THEN Temp$ = LEFT$(Temp$, LEN(Temp$) - 1) x$ = Temp$ + "\*.*" d$ = Temp$ + "\" File$ = DIR$(x$) DO WHILE LEN(File$) ListOfEm$ = ListOfEm$ + d$ + File$ File$ = DIR$("") LOOP END SUB FUNCTION CurDir$ 'reads the current directory DIM Reg AS RegTypeX DIM CurrentDrive AS INTEGER DIM CurrentDir AS STRING * 64 'Get current disk drive >>> Continued to next message * OLX 2.1 TD * Iraqi Bingo: B-52...F-16...M-1...F-18...F-117... --- TMail v1.30.4 * Origin: TC-AMS MLTBBS 2.2 - Minnetonka, MN (612)-938-4799 (1:282/7)
Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET