home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / euphoria / getnames.e < prev    next >
Text File  |  1994-02-19  |  891b  |  43 lines

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