pro SearchLib, cSearch, Directory, Archive, cFound @compile_opt.pro ; On error, return to caller ;+ ; NAME: ; SearchLib ; PURPOSE: ; Search for file. If not found try to extract it from .ARC archive ; CALLING SEQUENCE: ; SearchLib ( cSearch, Directory, Archive, cFound ) ; INPUTS: ; cSearch string name of requested file (name+extension) ; Directory string ; Archive string archive/library file ; OUTPUTS: ; cFound string name of requested file, if found. ; Otherwise the null string (''). ; CALLS: ; SetFileSpec, do_file, echo ; PROCEDURE: ; The search procedure is as follows: ; 1. Search for Directory+cSearch (if Directory = '' the search is in the ; working directory). If found, return. ; 2. Search in Archive. If found, return. ; 3. If not found, return cFound='' ; MODIFICATION HISTORY: ; JAN-1995, Paul Hick (UCSD) ;- bSet = 0B if Directory ne '' then begin n = strlen(Directory) if strmid(Directory,n-1,1) eq ':' then begin cLog = strmid(Directory,0,n-1) if not trnlog(cLog,cTemp) then begin message, /info, 'the logical '+cLog+' is not defined yet' cTemp = '[]' echo, /dir, 'Select directory for assignment',cTemp setlog, cLog, cTemp bSet = 1B endif endif endif dSearch = filepath(root=Directory,cSearch) SetFileSpec, dSearch, /parse, status=status if not status then message, 'error parsing '+dSearch cFound = (file_search(dSearch))[0] if cFound ne '' then return ; File found in Directory if Archive eq '' then message, 'no archive specified' cTemp = (file_search(Archive))[0] if cTemp eq '' then message, 'archive does not exist: '+Archive message, /info, 'attempt to extract from '+Archive spawn, '@x$com:tlb get '+Archive+' '+dSearch cFound = (file_search(dSearch))[0] if cFound ne '' then return ; File found in Directory ; TLB should extract into Directory (works for .TLB and .ARC archives) ; In case the extraction works only into the working directory, continue: cFound = (file_search(cSearch))[0] ; Check for file in working dir if cFound ne '' then cTemp = do_file(cFound, Directory, /move) cFound = (file_search(dSearch))[0] if cFound ne '' then return if bSet then dellog, cLog return & end