home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / pibterm / pibt41e3.zip / DIRLIST.SCR < prev    next >
Text File  |  1988-02-26  |  4KB  |  94 lines

  1. ***************************************************************************
  2. *   D I R L I S T . S C R  --- Demonstrates directory access in scripts   *
  3. ***************************************************************************
  4. *                                                                         *
  5. *    Script:  DirList.Scr                                                 *
  6. *                                                                         *
  7. *    Purpose: Demonstrates script facilities for listing directory        *
  8. *             entries.                                                    *
  9. *                                                                         *
  10. *    Invocation:                                                          *
  11. *                                                                         *
  12. *       Execute "DirList"                                                 *
  13. *                                                                         *
  14. ***************************************************************************
  15. *
  16. *                                   Wildcard for files
  17.  Declare FSpec String
  18. *                                   Attributes for search
  19.  Declare FAttr String
  20. *                                   File name
  21.  Declare FileName String
  22. *                                   File attributes
  23.  Declare FileAttr String
  24. *                                   File creation date
  25.  Declare FileDate String
  26. *                                   File creation time
  27.  Declare FileTime String
  28. *                                   File size in bytes
  29.  Declare FileSize String
  30. *                                   Report line
  31.  Declare ReportLine String
  32. *                                   Counts files found
  33.  Declare TotalFiles Integer
  34. *
  35. *                                   Get file spec to search for
  36. *
  37.  Writeln
  38.  Input "Enter file spec to search for: " FSpec
  39.  Writeln
  40. *
  41. *                                   If file spec null, quit.
  42. *
  43.  IF ( FSpec = '' ) THEN
  44.     Exit
  45.  ENDIF
  46. *
  47. *                                   Search for first file.
  48. *
  49.  DirFirst FSpec "" FileName FileAttr FileDate FileTime FileSize
  50. *
  51. *                                   No first file -- report that
  52. *                                   and quit.
  53. *
  54.  IF ( ( FileName = '' ) OR ( IOResult <> 0 ) ) THEN
  55.     Writeln
  56.     Writeln "No files found."
  57.     Writeln
  58.     Exit
  59.  ENDIF
  60. *                                   Set files found to 0.
  61.  Set TotalFiles = 0
  62. *
  63. *                                   Begin loop over rest of files.
  64. *
  65.  WHILE ( LENGTH( FileName ) <> 0 ) DO
  66. *
  67. *                                   Increment file count
  68. *
  69.     Set TotalFiles = TotalFiles + 1
  70. *
  71. *                                   Display file stuff
  72. *
  73.     Set FileName = CONCAT( FileName , DUPL( ' ' , 14 - LENGTH( FileName ) ) )
  74.     Set FileSize = CONCAT( DUPL( ' ' , 12 - LENGTH( FileSize ) ) , FileSize )
  75.     Set FileSize = CONCAT( FileSize , ' ' )
  76.     Set FileDate = CONCAT( FileDate , ' ' )
  77.     Set FileTime = CONCAT( FileTime , ' ' )
  78. *
  79.     Set ReportLine = CONCAT( CONCAT( FileName , FileSize ), FileDate )
  80.     Set ReportLine = CONCAT( CONCAT( ReportLine , FileTime ), FileAttr )
  81. *
  82.     Writeln ReportLine
  83. *                                   Get next file
  84. *
  85.     DirNext FileName FileAttr FileDate FileTime FileSize
  86. *
  87.  ENDWHILE
  88. *                                   Display final count of files
  89. *
  90.  Set ReportLine = CONCAT( 'Total files found: ', STRING( TotalFiles ) )
  91. *
  92.  Writeln
  93.  Writeln ReportLine
  94.