home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 24 / CD_ASCQ_24_0995.iso / vrac / homonlib.zip / DIRSTUFF.BAS < prev    next >
BASIC Source File  |  1995-04-13  |  3KB  |  94 lines

  1. DEFINT A-Z
  2.  
  3. DECLARE FUNCTION DirAttr$ (a)
  4. DECLARE FUNCTION DirDate$ (d&)
  5. DECLARE FUNCTION DirTime$ (t)
  6.  
  7. FUNCTION DirAttr$ (a)
  8. '****************************************************************************
  9. 'This function takes as its argument the integer received from the Attribute
  10. ' field of a DirType variable (See DIR.INC).  It then returns a 5-character
  11. ' string with letters representing the file or directory's attributes.
  12. '
  13. 'If all the attributes were set, the function would return "DRHSA", where:
  14. '
  15. '    D = Directory
  16. '    R = Read Only
  17. '    H = Hidden
  18. '    S = System
  19. '    A = Archive
  20. '
  21. 'If one or more attributes are missing, their location in the string will be
  22. ' blank.
  23. '
  24. 'Example: "    A" = A file with only an archive attribute.
  25. '         " RHS " = A read only, hidden, system file (such as IO.SYS).
  26. '
  27. 'This code is also useful to see how you can interpret the values on your
  28. ' own.  And you thought you would never find a use for the bitwise AND!
  29. '
  30. '****************************************************************************
  31.  
  32. s$ = "     "
  33.  
  34. IF (a AND 16) THEN MID$(s$, 1, 1) = "D"
  35. IF (a AND 1) THEN MID$(s$, 2, 1) = "R"
  36. IF (a AND 2) THEN MID$(s$, 3, 1) = "H"
  37. IF (a AND 4) THEN MID$(s$, 4, 1) = "S"
  38. IF (a AND 32) THEN MID$(s$, 5, 1) = "A"
  39.  
  40. DirAttr$ = s$
  41.  
  42. END FUNCTION
  43.  
  44. FUNCTION DirDate$ (d&)
  45. '****************************************************************************
  46. 'This function converts the long integer value of a DirType.EntryDate into a
  47. ' string in the form of MM/DD/YY.
  48. '****************************************************************************
  49.  
  50. x$ = LTRIM$(STR$(d&))
  51.  
  52. y$ = MID$(x$, 3, 2)
  53. m$ = MID$(x$, 5, 2)
  54. d$ = MID$(x$, 7, 2)
  55.  
  56. x$ = "/"
  57.  
  58. DirDate2$ = m$ + x$ + d$ + x$ + y$
  59.  
  60. END FUNCTION
  61.  
  62. FUNCTION DirTime$ (t)
  63. '****************************************************************************
  64. 'This function takes the integer value of a DirType.EntryTime field and
  65. ' converts it to a string in the form of HH:MMa.
  66. '****************************************************************************
  67.  
  68. z$ = "00"
  69. am$ = "a"
  70. pm$ = "p"
  71.  
  72. h = t \ 100                             'Convert hours first...
  73.  
  74. SELECT CASE h                           'Returned in 24 hour format:
  75.     CASE 0                   'Midnight
  76.         h = 12
  77.         ampm$ = am$
  78.     CASE IS < 12             'Morning
  79.         ampm$ = am$
  80.     CASE 12                  'Noon
  81.         ampm$ = pm$
  82.     CASE ELSE                'Afternoon
  83.         h = h - 12
  84.         ampm$ = pm$
  85. END SELECT
  86.  
  87. h$ = RIGHT$(z$ + LTRIM$(STR$(h)), 2)
  88. m$ = RIGHT$(z$ + LTRIM$(STR$(t)), 2)    'Minutes are easy...
  89.  
  90. DirTime2$ = h$ + ":" + m$ + ampm$
  91.  
  92. END FUNCTION
  93.  
  94.