*              Program to search for a string in a set for files   

    str progs.80(1000) 
    str rec.180, search.80, temp.80 
    str extension.80 
    str dir.80,file.100 
    int i, cnt, j 

    putc This program will search for a specified string in all 
    putc files in the current library having a particular extension.  
    putc This program is useful in searching a set of .C files 
    putc for all examples of a particular string (e.b46 g.b46  a variable name).
    putc 
    putc Extension? (e.b46 g.b46 , ".C") 
    getc extension 
    extension = extension // pad(4) 

    getdir dir 
    open [2,1] dir 
    loop for i = 1 to 1000 
      getf [2] rec 
      rec = rec // pad(20) 
      if rec{10,3} = extension{2,3} 
        cnt = cnt + 1 
        temp = rec{1,8} 
        temp = trm(temp) // extension 
        progs(cnt) = temp      
      end 
    repeat 
eof2: close [2] 
*   stop 

    loop 
      putc Search string?  
      getc search 
      search = trm(search) 
      loop for i = 1 to cnt 
        putc ~progs(i)  ...  
        file = dir // "\" // progs(i) 
        open [1,1] file 
        loop for j = 1 to 100000 
          getf [1] rec 
          if rec con search 
            putc ~j  ...  
          end 
        repeat 
eof1: 
        close [1] 
        putc 
      repeat 
    repeat 
    run