SBP ========================================================== SRCHPGM.SBP - Provides the facility to search a Directory for a string value in the following SB object types. - Programs - Database Definition Files - Forms - Query - Updates - Labels We have found this routine very useful during the development of large applications. It is posted to the SPCFORUM in the hope that others will gain from its use and to further encourage the devlopment of addons and development tools for use with SB. We however do not guarantee the results from its use, and have had problems with the routine that returns the files within a directory (GetFileNames), though we think this has been fixed. If anyone has a decent routine to do this we would be very interested in the details. Hope this is of some help to all you developers out there. Regards Jon Knowles (100273,237) ARC Systems London Instructions for use : 1. Run this program 2. From Search menu select 'Search for...' 3. Select search type required 4. Enter the search string. - If you wish to search for a SB program Command such as 'DEBUG' then enter the tokenised hex value (FF8C) as your search string and select the Hex Search Checkbox. The search routine will then perfom a search for the specific hex value. - To determine the tokenised hex value for an SB command word. Enter the single command and save to a dummy program file. Use a editor which will allow you to view the file HEX codes to determine tokenised Hex value. Enter the Hex codes as the search string and select the Hex search checkbox. 5. Select OK and you will be presented with an Open file Dialog. Select a file from the directory you wish to search. The search program will then search for the search string in all the files in the directory selected. ========================================================== main()   1,0,1,"&Search","","Search a program search file" 1,1,1,"&Search for...","SearchPgm","Search a String within a program." 1,2,1,"E&xit","Exit","Exit program search"  2,0,1,"&Printer","","Printer Setup" 2,1,1,"P&rint setup...","PrinterSetup","Change the printer configuration" 2,2,1,"Pa&ge setup...","PageSetup","Change page dimensions and other settings"   "Please select an option" aY    =================================================== Rountine to process a search selection. =================================================== SearchPgm() display search selection dialog "Please enter search details. You may use ? as part of the search string..." Opt1$"SBP" "SrchType",0,0,146,150,"Search Details","System",10 |"SrchType",4,28,2,90,104,0," Type " |"SrchType",3,35,12,80,12,0,"SB File definition","SBD",Opt1$ |"SrchType",3,35,27,80,12,0,"SB Labels","SBL",Opt1$ |"SrchType",3,35,42,80,12,0,"SB Programs","SBP",Opt1$ |"SrchType",3,35,57,80,12,0,"SB Querys","SBQ",Opt1$ |"SrchType",3,35,72,80,12,0,"SB Updates","SBU",Opt1$ |"SrchType",3,35,87,80,12,0,"SB Forms","SBV",Opt1$ |"SrchType",6,28,110,90,14,0,0,SrchString$,20 |"SrchType",5,3,113,24,11,0,"String :" |"SrchType",2,90,130,49,15,0,"Hex Search","Y","N",HexSrch$ |"SrchType",1,3,132,31,14,1,"OK",1,1 |"SrchType",1,40,132,42,14,0,"Cancel",0,0 "SrchType",bn% "SrchType"' remove dialog bn%0p' end routine  fpath$"*."Opt1$ "Please select the search directory :","",26,rtc%,fpath$ rtc%0p' user cancelled FileNames$ FileNames$(500) a_size%500 fpath$path(fpath$) "Building file list..." Dirarray(fpath$,Opt1$,FileNames$(),a_size%,Counter%%,rtc%)' fills FileNames$ with a list of files from specified directory.  =================================================== Allow for the selection of the Output destination ===================================================  display dialog to allow selection of the report destination Opt1%3 "RptDst1",0,0,133,118,"Report Destination","System",10 |"RptDst1",4,11,7,109,76,0," Destination " |"RptDst1",3,20,20,87,10,0,"Printer",1,Opt1% |"RptDst1",3,20,35,87,10,0,"Window",3,Opt1% |"RptDst1",3,20,50,87,10,0,"Screen",2,Opt1% |"RptDst1",1,74,90,37,15,0,"Cancel",0,0 |"RptDst1",1,13,90,37,15,1,"Ok",1,1 "Please select the detination of the report output." "RptDst1",bn% "RptDst1"' remove dialog bn%0prtc%0:' end routine  process the options selected e Opt1% 1 ;' set output to printer  2 "Press space bar for the next page or 'CTRL + Break' to end report."  3  "Program Search for : "SrchString$  { {" Program search for : "SrchString$ { {" Search Directory : "fpath$ { {" Search date : "(Q,"dd:mm:yy") { {" Program file" {" ============" {  If a Hex search requested then convert the Hex codes entered to their equivalent Character value. HexSrch$"Y"p' convert string from HEX l%1q/(SrchString$)k2 HSrchString$HSrchString$(dec(,(SrchString$,l%,2)))  SrchString$"*"HSrchString$"*" ^ SrchString$"*"SrchString$"*"  loop to search each program in turn as listed in the FileNames$ file n%0qCounter%% "Searching program ">(FileNames$(n%))"."Opt1$ HexSrch$"Y" Opt1$"SBV"p' search for hex equiv FileNames$(n%)"."Opt1$ _e67 & cInputLine$ OB("*") InputLine$SrchString$p NoCount%NoCount%1 {@2;>(FileNames$(n%))"."Opt1$   cInputLine$   _67 ^' serach for text string fpath$FileNames$(n%)"."Opt1$SrchString$p NoCount%NoCount%1 {@2;>(FileNames$(n%))"."Opt1$      { { {@2;"Total no. of pgms :";@25;(NoCount%,"9999") ;   FileNames$  =============================================================================== This routine will write details of the files contain in a directory to an array. Pathname$ - details of the directory to be listed Extension$ - files extension to be searched for ie. SBP FileNames$() - an array to hold the file list Counter%% - number of files listed rtc% - error return code = 0 if error ARC Systems Jan 1994 ===============================================================================  Dirarray(Pathname$,Extension$,FileNames$(),a_size%,Counter%%,rtc%) if the path is blank then allow to select a path Pathname$""p selpath$"*.*" "Select path","",26,rtc%,selpath$ rtc%0p Pathname$path (selpath$) rtc%0  GetFileNames(Pathname$,Extension$,FileNames$(),a_size%,Counter%%) trim the file extensions i%0 i% Counter%% FileNames$(i%)""p  FileNames$(i%)+(FileNames$(i%),?(FileNames$(i%),".")1)  i%i%1  rtc%1  ------------------------------------------------------------------------ Routine to find all the filenames of a particular extension in a directory, both supplied by the calling routine. ------------------------------------------------------------------------ GetFileNames(Pathname$,Extension$,FileNames$(),a_size%,Counter%%) TempFileName$PathName$"zz"(Q,"mmddyy")".tmp" SearchString$PathName$"*."Extension$ o"Courier New,8,0,49,0" qTempFileName$ {SearchString$  Counter%%0 TempFileName$ cInputLine$ OB("*") O(InputLine$"*Directory List*") InputLine$""p' process if not heading or blank line  /(InputLine$)0  Counter%%a_size%2pa_size%a_size%2: FileNames$(a_size%)' double the array size  ?(InputLine$," ")0p FileNames$(Counter%%)F(+(InputLine$,?(InputLine$," ")))  ^ FileNames$(Counter%%)InputLine$   InputLine$H(-(InputLine$,(/(InputLine$)/(Filenames$(Counter%%)))))  FileNames$(Counter%%)=(FileNames$(Counter%%))  Counter%%Counter%%1   cInputLine$   TempFileName$ Counter%%Counter%%1