'=========================================================================== ' Subject: LB CODE MANAGER Date: 12-17-98 (17:52) ' Author: David Szafranski Code: LB ' Origin: digital_paris@csi.com Packet: LIBERTY.ABC '=========================================================================== 'WhatIsIt? 1.0 is a LB code manager program to find all *.bas files on a drive 'and then search the first part of each selected .bas file for comments. 'If a file is commented at the start of the file, then 'this may help to figure out what each program does without loading 'each file from LB. The program also searches the selected file 'for dll's that were called or for bmp's that were used. 'And if that's not enough, you can search through the comments to locate 'the files that match your topic! So, time to start commenting ALL your files 'and snippets so you can find them later...maybe? or maybe not! 'Feel free to expand/change! David Szafranski August 1998 nomainwin WindowWidth = 560 WindowHeight = 570 origWidth = 560 origHeight = 570 UpperLeftX = int((DisplayWidth - WindowWidth) / 2) UpperLeftY = int((DisplayHeight - WindowHeight) / 2) graphicbox #main.box, 0, 0, 552, 540 button #main.getem, "GetEmAll!", [search], UL, 1, 1, 91, 25 button #main.next, "Next!", [nextFile], UL, 92, 1, 91, 25 button #main.previous, "Previous!", [previous], UL, 183, 1, 91, 25 button #main.launch, "OpenIt!", [launch], UL, 274, 1, 91, 25 button #main.delete, "DeleteIt!", [delete], UL, 365, 1, 91, 25 button #main.quit, "Quit!", [quit], UL, 456, 1, 95, 25 button #main.findit, " Go BasBot!", [basbot], UL, 275, 419, 100, 25 combobox #main.drv, drv$(, [mainLoop], 15, 50, 50, 80 combobox #main.list, list$(, [getComments], 85, 50, 450, 120 combobox #main.comments, results$(, [getBasBotComments], 125, 454, 409, 120 textbox #main.basbot, 115, 419, 150, 25 texteditor #main.info, 15, 105, 520, 170 texteditor #main.dlls, 15, 305, 250, 80 texteditor #main.bmps, 285, 305, 250, 80 menu #main, &File, &Exit, [quit] menu #main, &GetEm, "&Get All *.bas Files", [search] menu #main, &Launch, "Run Selected LB File", [launch] graphicbox #main.statusBar, 0, 493, 552, 30 textbox #main.lastFile, 171, 502, 299, 17 open "What is it?" for window as #main 'note: must use a 'window' type with resizehandler command print #main, "trapclose [quit]" print #main, "resizehandler [redraw]" Font1$="!font Arial 6 15" Font2$="!font Arial_Bold 6 15" Font3$ = "font Arial 6 15" print #main.getem, Font2$ print #main.next, Font2$ print #main.previous, Font2$ print #main.launch, Font2$ print #main.delete, Font2$ print #main.quit, Font2$ print #main.findit, Font2$ print #main.box, Font3$ print #main.statusBar, Font3$ print #main.drv, Font3$ print #main.list, Font3$ print #main.comments, Font3$ print #main.basbot, Font1$ print #main.lastFile, Font1$ print #main.info, Font1$ print #main.dlls, Font1$ print #main.bmps, Font1$ print #main.statusBar, "fill lightgray; flush" wstatbar = 560 hstatbar = 30 gap = 3 'border width for status bar x = gap-1 'draw outside raisedd3D box y = gap-1 boxWidth = wstatbar-(2*(gap-1))-12 boxHeight = hstatbar-(2*(gap-1))-2 outsideBoxWidth=boxWidth outsideBoxHeight=boxHeight gosub [raisedStatBarBox] x = 2*gap 'draw first recessed3D status bar box for files found y = 2*gap boxWidth = 160 boxHeight = outsideBoxHeight-(2*gap) statusBoxHeight = boxHeight gosub [recessedStatBarBox] x = 3*gap+160 'draw second recessed3D status bar box for file selection y = 2*gap boxWidth = 300 boxHeight = outsideBoxHeight-(2*gap) statusBoxHeight = boxHeight gosub [recessedStatBarBox] print #main.box, "fill lightgray; flush" print #main.box, "color darkblue; backcolor darkblue" print #main.box, "place 0 396" print #main.box, "down; boxfilled 550 491; up; flush" print #main.box, "color white" print #main.box, "place 17 434" print #main.box, "\Search Topics:" print #main.box, "place 17 469" print #main.box, "\Search Results:" boxTitle$ = "Drv" ' use 3D box subroutine to draw boxes clr$ = "black" 'text color bkclr$ = "lightgray" 'backcolor x= 10 'x placement of box y = 35 'y placement of box boxWidth = 58 'box width boxHeight = 42 'box height gosub [draw3DBox] 'do it boxTitle$ = "List of all *.bas files" ' use 3D box subroutine to draw boxes x= 80 'x placement of box y = 35 'y placement of box boxWidth = 458 'box width boxHeight = 42 'box height gosub [draw3DBox] 'do it boxTitle$ = "File comments" ' use 3D box subroutine to draw boxes x= 10 'x placement of box y = 90 'y placement of box boxWidth = 528 'box width boxHeight = 189 'box height gosub [draw3DBox] 'do it boxTitle$ = ".dll's called" ' use 3D box subroutine to draw boxes x= 10 'x placement of box y = 290 'y placement of box boxWidth = 258 'box width boxHeight = 99 'box height gosub [draw3DBox] 'do it boxTitle$ = "bmpbuttons or *.bmp's loaded" ' use 3D box subroutine to draw boxes x= 280 'x placement of box y = 290 'y placement of box boxWidth = 258 'box width boxHeight = 99 'box height gosub [draw3DBox] 'do it boxTitle$ = "Search basBot!" ' use 3D box subroutine to draw boxes clr$ = "yellow" 'text color bkclr$ = "darkblue" 'backcolor x= 10 'x placement of box y = 404 'y placement of box boxWidth = 528 'box width boxHeight = 78 'box height gosub [draw3DBox] 'do it x=1 'draw raised 3D box around basBot box y=395 boxWidth = 548 boxHeight = 97 gosub [raised3DBox] dim files$(10,10) 'dim for files statement dim list$(1000) 'list of all files fitting search - change value as necessary dim comments$(10) 'comments for each file dim results$(250) 'list of files which are result of search topic string dim dirs1$(500) 'copy of previous list of subdirectories to be searched dim dirs2$(500) 'list of subdirectories to be searched dim dl$(50) 'list of dll's found in file dim topic$(25) 'list of search words extDefIndex = 1 'set up default index values for variables drvsDefIndex = 2 commFlag = 0 'initiate flag for comments array comments() drvs$ = Drives$ 'list of currently available drives data$ = drvs$ 'create drive array for combobox count = 0 while data$ <> "" length = len(data$) x = instr(data$, " ") if x = 0 then drv$(count) = trim$(data$)+ "\": data$ = "" : goto [finish1] drv$(count) = left$(data$, x-1)+"\" data$ = right$(data$,length-x) count = count + 1 [finish1] wend print #main.drv, "reload" print #main.drv, "selectindex "; drvsDefIndex [mainLoop] input aVar$ goto [mainLoop] '==================Start of Search Routine===================== [search] cursor hourglass 'get parameters from comboboxes ' print #main.ext, "selection?" : input #main.ext, searchExt$ searchExt$ = "*.bas" 'type of file to search for print #main.drv, "selection?" : input #main.drv, initDrv$ ' initDrv$ = "c:\" 'starting search path totalFound = 0 'total no of files found countDir1 = 1 'directory counter countDir2 = 0 'directory counter redim files$(10,10) 'dim for files statement redim list$(1000) 'list of all files fitting search - change value as necessary redim dirs1$(500) 'copy of previous list of subdirectories to be searched redim dirs2$(500) 'list of subdirectories to be searched dirs$(1) = "" while countDir1 >0 'quit loop when no more subdirs are found that have subdirs totalSubs = 0 'reset total number of subdirs countDir2 = 0 'reset count of subdirs for j = 1 to countDir1 startDir$ = initDrv$ + right$(dirs1$(j),len(dirs1$(j))-1) 'remove \ from directory string gosub [getDir] 'call the "files" command if quantityFiles = 0 then goto [subDirs] num = 1 for i = totalFound-quantityFiles to totalFound-1 list$(i) = left$(initDrv$,len(initDrv$)-1) + dirs1$(j) + "\" + files$(num,0) 'keep track of files found and put in list$() num = num + 1 next i [subDirs] if quantitySubs = 0 then goto [nextJ] for i = quantityFiles+1 to quantityFiles+quantitySubs 'keep track of names of subdir found with more subdirs dirs2$(i - quantityFiles + totalSubs) = files$(i,0) next i totalSubs = totalSubs + quantitySubs [nextJ] next j for i = 1 to countDir2 'replace list of old subdirs with new list dirs1$(i) = dirs2$(i) next i countDir1 = countDir2 'replace last count of subdirs with new count wend 'end of search routine '============================================================= sort list$(, 0, totalFound-1 'Sort the list of files in list$() print #main.list, "reload" 'load list of files into listbox print #main.list, "selectindex 1" 'show first file in combobox print #main.list, "selection?" input #main.list, fileName$ lastFileName$ = fileName$ gosub [changeTitleBar] cursor normal text$ = "*.bas files found: "+ str$(totalFound) gosub [setStatusText] ' goto [mainLoop] [getComments] ' print #main.list, "setfocus" print #main.list, "selection?" input #main.list, fileName$ lastFileName$ = fileName$ gosub [changeTitleBar] [comments] cursor hourglass print #main.info, "!cls" print #main.dlls, "!cls" print #main.bmps, "!cls" open fileName$ for input as #readFile 'get comments from selected file test$ = "'" chk$ = "'" while chk$ = test$ line input #readFile, line$ 'get line of text line$ = trim$(line$) 'get rid of leading/trailing spaces if line$ = "" then [skipline] 'skip blank lines chk$ = left$(line$,1) 'get first character in line of text if chk$ = test$ then print #main.info, line$ 'if first charcter is ' then print it [skipline] wend close #readFile open fileName$ for input as #readFile 'check every line for dll calls test$ = "for dll" chk$ = chr$(34) ' this is double quote character count = 0 dl$(0) = "" while eof(#readFile) = 0 line input #readFile, line$ 'get line of text line$ = trim$(line$) 'get rid of leading/trailing spaces line$ = lower$(line$) 'convert to lowercase x = instr(line$,test$,1) 'seach for location of 'for dll' if x = 0 then [nextLine] 'if not found, go to next line x1 = instr(line$,chk$,1) 'now look for first double quote char if x1 = 0 then [nextLine] 'if not found, go to next line x2 = instr(line$,chk$,x1+1) 'get second double quote char if x2 = 0 then [nextLine] 'if not found, go to next line if x2 > x then [nextLine] 'if quote found after then skip line dll$ = mid$(line$,x1+1,x2-x1-1) 'get name of dll save$ = "" for i = 0 to count 'check to see if dll is new if dl$(i) = dll$ then save$ = "no" next i if save$ = "" then 'save each new dll name in array dl$() dl$(count) = dll$ print #main.dlls, dll$ count = count + 1 end if [nextLine] wend close #readFile open fileName$ for input as #readFile 'check every line for bmpbutton calls test$ = "bmpbutton" chk$ = chr$(34) ' this is double quote character while eof(#readFile) = 0 line input #readFile, line$ 'get line of text line$ = trim$(line$) 'get rid of leading/trailing spaces line$ = lower$(line$) 'convert to lowercase x = instr(line$,test$,1) 'search for location of 'loadbmp' if x = 0 then [skip] 'if not found, go to next line x1 = instr(line$,chk$,1) 'now look for first double quote char if x1 = 0 then [skip] 'if first double quote not found then skip line if x1 < x then [skip] 'if first double quote is before bmpbutton then skip line x2 = instr(line$,chk$,x1+1) 'get second double quote char if x2 = 0 then [skip] 'if second double quote not found then skip line bmp$ = mid$(line$,x1+1,x2-x1-1) 'get name of bmp print #main.bmps, bmp$ 'print it into textbox [skip] wend close #readFile open fileName$ for input as #readFile 'check every line for loadbmp calls test$ = "loadbmp" test2$ = "unloadbmp" chk$ = chr$(34) ' this is double quote character while eof(#readFile) = 0 line input #readFile, line$ 'get line of text line$ = trim$(line$) 'get rid of leading/trailing spaces line$ = lower$(line$) 'convert to lowercase y = instr(line$,test2$,1) 'search for 'unloadbmp' if y > 0 then [nextOne] 'if found, skip line x = instr(line$,test$,1) 'search for location of 'loadbmp' if x = 0 then [nextOne] 'if not found, go to next line x1 = instr(line$,chk$,1) 'now look for first double quote char x2 = instr(line$,chk$,x1+1) 'get second double quote char x3 = instr(line$,chk$,x2+1) 'get third double quote char if x3 = 0 then [nextOne] 'skip line if third double quote not found x4 = instr(line$,chk$,x3+1) 'get last double quote char bmp$ = mid$(line$,x3+1,x4-x3-1) 'get name of bmp print #main.bmps, bmp$ [nextOne] wend close #readFile cursor normal goto [mainLoop] [launch] ' print #main.list, "selection?" ' input #main.list, fileName$ if lastFileName$ = "" then goto [mainLoop] liberty$ = "c:\liberty\liberty.exe" ' run "c:\liberty\liberty.exe c:\liberty\examples\whatisit.bas" run liberty$ + " " + lastFileName$ goto [mainLoop] [nextFile] print #main.list, "selectionindex?" input #main.list, index index = index + 1 if index > totalFound then goto [mainLoop] print #main.list, "selectindex "; index print #main.list, "selection?" input #main.list, fileName$ if fileName$ = "" then goto [mainLoop] lastFileName$ = fileName$ gosub [changeTitleBar] goto [comments] [previous] print #main.list, "selectionindex?" input #main.list, index index = index - 1 if index = 1 then goto [mainLoop] print #main.list, "selectindex "; index print #main.list, "selection?" input #main.list, fileName$ if fileName$ = "" then goto [mainLoop] lastFileName$ = fileName$ gosub [changeTitleBar] goto [comments] [delete] if lastFileName$ = "" then goto [mainLoop] text$ = "Are you sure you want to DELETE " total$ = text$ + lastFileName$ confirm total$; answer$ if answer$ = "no" then [mainLoop] kill lastFileName$ commFlag = 0 goto [search] [basbot] 'search comments for search topic string and return list of files that match print #main.list, "selection?" input #main.list, fileName$ if fileName$ = "" then notice "Please press GetEmAll! first!" goto [mainLoop] end if cursor hourglass redim results$(250) 'clear results$() for new search if commFlag = 1 then [seek] 'check to see if comment array has already been built or if changes have been made redim comments$(totalFound) 'redim comments array using totalFound for i = 0 to totalFound-1 'build comments array comments$() fileName$ = list$(i) open fileName$ for input as #readFile 'get comments from selected file test$ = "'" chk$ = "'" while chk$ = test$ line input #readFile, line$ 'get line of text line$ = trim$(line$) 'get rid of leading/trailing spaces line$ = lower$(line$) 'all lowercase if left$(line$,1) = "" then [skipoverit] 'skip line if blank chk$ = left$(line$,1) 'get first character in line of text if chk$ = test$ then comments$(i) = comments$(i) + line$ + " " [skipoverit] wend close #readFile next i commFlag = 1 [seek] print #main.basbot, "!contents?" input #main.basbot, top$ top$ = lower$(top$) 'all lowercase search index = 0 temp$ = "?" while temp$ <> "" 'find number of words in search topic$(index) = word$(top$, index+1) 'place search words in topic$() temp$ = topic$(index) if temp$ <> "" then index = index + 1 'count of no of search words wend results$(0) = "" count = 0 for j= 0 to index for i = 0 to totalFound-1 if instr(comments$(i),topic$(j),1) <> 0 then found$ = list$(i) save$ = "" for k = 0 to count 'check to see if file is new if results$(i) = found$ then save$ = "no" next k if save$ = "" then 'save each new file name in array results$() results$(count) = found$ count = count + 1 end if end if next i next j cursor normal text$ = "Files found: "+ str$(count) gosub [setStatusText] if count = 0 then notice "No matches found. Try another topic!" : print #main.basbot, " " : goto [mainLoop] print #main.comments, "reload" 'load list of files into listbox print #main.comments, "selectindex 1" 'show first file in combobox print #main.comments, "selection?" input #main.comments, fileName$ lastFileName$ = fileName$ gosub [changeTitleBar] goto [comments] ' goto [mainLoop] [getBasBotComments] print #main.comments, "selection?" input #main.comments, fileName$ lastFileName$ = fileName$ gosub [changeTitleBar] goto [comments] [redraw] newWidth = WindowWidth newHeight = WindowHeight print #main.box, "locate 0 0 "; newWidth; " "; newHeight print #main.statusBar, "locate "; 0; " "; newHeight-hstatbar; " "; newWidth; " "; hstatbar print #main.lastFile, "!locate "; 171; " "; newHeight-hstatbar+8; " "; 299; " "; 17 print #main, "refresh" goto [mainLoop] [quit] close #main end [getDir] files startDir$, searchExt$, files$( 'call files function quantityFiles = val(files$(0,0)) 'no of files found quantitySubs = val(files$(0,1)) 'no of subdirs found totalFound = totalFound + quantityFiles 'total no of files found countDir2 = countDir2 + quantitySubs 'total no of subdirs found this go around return [draw3DBox] ' Routine to draw a 3D box with a "title" in the top line - for graphic windows ' x is the x position to start drawing box ' y is the y position to start drawing box ' boxWidth is the desired box width ' boxHeight is the desired box height ' boxTitle$ is the desired box "title" print #main.box, "color darkgray ; down" print #main.box, "place "; x; " "; y print #main.box, "box "; boxWidth + x; " "; boxHeight+y print #main.box, "color white" print #main.box, "place "; x+1; " "; y+1 print #main.box, "line "; x+1; " "; y+1; " "; x+1; " "; y+boxHeight-2 print #main.box, "place "; x+1; " "; y+1 print #main.box, "line "; x+1; " "; y+1; " "; x + boxWidth - 2; " "; y+1 print #main.box, "place "; x; " "; y+boxHeight print #main.box, "line "; x; " "; y+boxHeight; " "; x+boxWidth +1; " "; y+boxHeight print #main.box, "place "; x+boxWidth; " "; y print #main.box, "line "; x+boxWidth; " "; y; " "; x+boxWidth; " "; y+boxHeight+1 print #main.box, "flush" print #main.box, "color "; clr$ 'print text color print #main.box, "place "; x+6; " "; y+5 'location print #main.box, "backcolor "; bkclr$ 'backcolor print #main.box, "\ "; boxTitle$ + ":" 'Title of Box print #main.box, "flush" 'flush return [changeTitleBar] 'set text in second recessed3D status bar box - textbox print #main.lastFile, lastFileName$ return [raisedStatBarBox] ' x is the x position to start drawing box ' y is the y position to start drawing box ' boxWidth is the desired box width ' boxHeight is the desired box height print #main.statusBar, "color white ; down" print #main.statusBar, "place "; x; " "; y print #main.statusBar, "line "; x; " "; y; " "; x; " "; y+boxHeight print #main.statusBar, "place "; x; " "; y print #main.statusBar, "line "; x; " "; y; " "; x + boxWidth; " "; y print #main.statusBar, "color darkgray" print #main.statusBar, "place "; x; " "; y+boxHeight print #main.statusBar, "line "; x; " "; y+boxHeight; " "; x+boxWidth; " "; y+boxHeight print #main.statusBar, "place "; x+boxWidth; " "; y print #main.statusBar, "line "; x+boxWidth; " "; y; " "; x+boxWidth; " "; y+boxHeight print #main.statusBar, "flush" return [recessedStatBarBox] ' x is the x position to start drawing box ' y is the y position to start drawing box ' boxWidth is the desired box width ' boxHeight is the desired box height print #main.statusBar, "color darkgray ; down" print #main.statusBar, "place "; x; " "; y print #main.statusBar, "line "; x; " "; y; " "; x; " "; y+boxHeight print #main.statusBar, "place "; x; " "; y print #main.statusBar, "line "; x; " "; y; " "; x + boxWidth; " "; y print #main.statusBar, "color white" print #main.statusBar, "place "; x; " "; y+boxHeight print #main.statusBar, "line "; x; " "; y+boxHeight; " "; x+boxWidth; " "; y+boxHeight print #main.statusBar, "place "; x+boxWidth; " "; y print #main.statusBar, "line "; x+boxWidth; " "; y; " "; x+boxWidth; " "; y+boxHeight print #main.statusBar, "flush" return [raised3DBox] ' x is the x position to start drawing box ' y is the y position to start drawing box ' boxWidth is the desired box width ' boxHeight is the desired box height print #main.box, "color white ; down" print #main.box, "place "; x; " "; y print #main.box, "line "; x; " "; y; " "; x; " "; y+boxHeight-1 print #main.box, "place "; x; " "; y print #main.box, "line "; x; " "; y; " "; x + boxWidth-1; " "; y print #main.box, "color white ; down" print #main.box, "place "; x-1; " "; y-1 print #main.box, "line "; x-1; " "; y-1; " "; x-1; " "; y+boxHeight print #main.box, "place "; x-1; " "; y-1 print #main.box, "line "; x-1; " "; y-1; " "; x + boxWidth; " "; y-1 print #main.box, "color darkgray" print #main.box, "place "; x; " "; y+boxHeight-1 print #main.box, "line "; x; " "; y+boxHeight-1; " "; x+boxWidth-1; " "; y+boxHeight-1 print #main.box, "place "; x+boxWidth-1; " "; y print #main.box, "line "; x+boxWidth-1; " "; y; " "; x+boxWidth-1; " "; y+boxHeight print #main.box, "color black" print #main.box, "place "; x-1; " "; y+boxHeight print #main.box, "line "; x-1; " "; y+boxHeight; " "; x+boxWidth; " "; y+boxHeight print #main.box, "place "; x+boxWidth; " "; y-1 print #main.box, "line "; x+boxWidth; " "; y-1; " "; x+boxWidth; " "; y+boxHeight+1 print #main.box, "flush" return [setStatusText] 'set text in first recessed3D status box print #main.statusBar, "color black; backcolor lightgray" print #main.statusBar, "place 7 20" 'erase previous text print #main.statusBar, "\ " print #main.statusBar, "place 7 20" 'print new text print #main.statusBar, "\ "; text$ print #main.statusBar, "flush" return