L O S T 
 
            Program to find a string in a set of path names 
 
 
      str topdir.80, dirnames.100(10000) 
      str wk1.100, skey.80, wk2.100 
      int loaddir, readdir, key 
      int cnt 


      putc Program to find a string in a set of path names 
Q1:   putc 
      putc Top of path (directory to search)? 
      getc topdir 
      topdir = trm(topdir) 
      if topdir = "" 
        goto Q1 
      end 

Q2: 
      putc search string? <return = stop> ...  
      getc .t32 skey 
      skey = trm(skey) 
      if skey = "" 
        putc 
        putc Done!  
        putc 
        stop       
      end 
      skey = lcs(skey) 

      loaddir = 0 
      readdir = 0 
      cnt = 0 

      perform procdir (topdir) 
      readdir = loaddir 
L1: 
      if readdir > 0         
        wk1 = lcs(dirnames(readdir)) 
        wk2 = rev(wk1) 
        if wk2 con "\" 
          wk2 = wk2{1,mpt-1} 
        end 
        wk2 = rev(wk2) 

        perform report 

        if wk2 con skey 
          putc dir   ~wk1 
          if len(wk1) < 76 
            putc ~wk1 .t77 dir
          else 
            putc ~wk1  directory 
          end 
        end 

        --loaddir 
        perform procdir (wk1) 
        readdir = loaddir 
        goto L1 
      end 
      putc .w5 ~cnt  Files searched 
      putc 
      goto Q2 


      procedure procdir (dirname) 
        str dirname.100, pathname.100 
        str line.80, temp1.8, temp2.3, fname.12 
        str wk1.100 

        getvalue dirname 

        open [1,1] dirname 
        loop 
          getf [1] line 
          line = line // pad(15) 
          if line{1} <> " " 
            temp1 = line{1,8} 
            temp1 = trm(temp1) 
            temp2 = line{10,3} 
            temp2 = trm(temp2) 
            fname = temp1 
            if temp2 <> "" and line{14} = "<"    /* directory with dot 
              goto PASS 
            end 

            if temp2 <> ""                
              fname = fname // "." // temp2 
            end 
            if line{14} = "<" 
              if dirname{..} = "\" or dirname{..} = "/" 
                pathname = dirname // fname 
              else 
                pathname = dirname // "\" // fname 
              end 
              ++loaddir 
              dirnames(loaddir) = pathname 
            else 
              fname = lcs(fname) 

              perform report 

              if fname con skey 
                wk1 = lcs(dirname) // "\" // fname 
                putc file  ~wk1 
                if len(wk1) < 76 
                  putc ~wk1 .t77 file 
                else 
                  putc ~wk1  file 
                end 
              end 
            end 
PASS: 
          end 
        repeat 
eof1: 
        close [1] 
      return 

      procedure report 
        int i 
        ++cnt 
        i = cnt / 100 
        if rem = 0 
          putc .w5 ~cnt  Files searched .b27 &a0C...  
        end 
      return 

      run