home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / arexx / misc_arexx / getdir.rexx < prev    next >
OS/2 REXX Batch file  |  1996-10-15  |  2KB  |  85 lines

  1. /* 
  2.  
  3. $VER: GetDir.rexx 1.0 (12.Sep.96)
  4.  
  5.  
  6.            GetDir v1.0 by Fini 'Warp' Alring / GiGA Prod. ©1996 
  7.  
  8.             Purpose:  to list a dir into an array called Files.
  9.  
  10.                   Supports AmigaDOS pattern parsing! :·)
  11.                       
  12.                      Sorts the files, in alpha order!
  13.                       
  14.                 Use the function, but remember the credits! ;·D
  15.                 
  16.                   Getdir makes use of C:List and C:Sort.
  17. */
  18.  
  19.  
  20. Parse arg Source
  21.  
  22. if ~show('l','rexxsupport.library') then do
  23.    call addlib('rexxsupport.library',0,-30,0)
  24. end
  25.  
  26. Files. = '' 
  27.  
  28. Num_Files = GetDir(Source)
  29.  
  30. say 
  31.  
  32. do i = 1 to Num_files
  33.     say files.i
  34. end
  35.  
  36. say ; Say 'Number of files:'Num_files
  37.  
  38. exit(0)
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45. /*   ///////////////Program End///////////////// */
  46.  
  47. /*   /////////////Functions Begin/////////////  */
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54. GetDir: Procedure Expose Files.
  55.  
  56.     Parse Arg SourceDir
  57.     
  58.     File_count = 0
  59.     
  60.     Address Command 'C:List >NIL: 'SourceDir' TO T:Mfile1.tmp FILES LFORMAT "%s"'
  61.     Filesize = word(statef('T:Mfile1.tmp'),2)
  62.      if value(filesize) > 0 then Address Command 'C:Sort T:Mfile1.tmp T:Mfile2.tmp CASE >NIL:'
  63.      
  64.     Success = Open(DATA,'T:Mfile2.tmp','Read')    
  65.     if success = 1 then do 
  66.         f = 1
  67.         Do while eof(DATA) ~= 1
  68.             Files.f = Readln(DATA)
  69.             f = f + 1
  70.         end
  71.         
  72.         Call Close(DATA)
  73.         Address Command "C:Delete T:Mfile2.tmp Quiet"
  74.             
  75.         f = 1
  76.         do while length(Files.F)>1
  77.             File_count = File_count + 1
  78.             F = F + 1
  79.         end
  80.     end
  81.     
  82.     Address Command "C:Delete T:Mfile1.tmp Quiet"
  83.     
  84. Return File_count
  85.