home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / euphor10.zip / GETNAMES.E < prev    next >
Text File  |  1993-01-18  |  865b  |  42 lines

  1. -- get file names from dir command
  2.  
  3. function no_blanks(sequence x)
  4. -- squeeze out all blanks in a string
  5.     sequence nbx
  6.  
  7.     nbx = ""
  8.     for i = 1 to length(x) do
  9.         if x[i] != ' ' then
  10.         nbx = nbx & x[i]
  11.         end if
  12.     end for
  13.     return nbx
  14. end function
  15.  
  16. global function get_names()
  17. -- convert the output from a plain dir command into a 
  18. -- sequence of file names 
  19.     sequence file_names
  20.     object name
  21.  
  22.     file_names = {}
  23.     while 1 do
  24.     name = gets(0)
  25.     if atom(name) then
  26.         exit
  27.     end if
  28.     if length(name) >= 12 then
  29.         if name[1] >= 'A' and name[1] <= 'Z' then
  30.         if not match("DIR", name[9..length(name)]) then
  31.             name = name[1..12]
  32.             name[9] = '.'
  33.             file_names = append(file_names, no_blanks(name))
  34.         end if
  35.         end if
  36.         end if
  37.     end while
  38.     return file_names
  39. end function
  40.  
  41.  
  42.