home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / dspace10.zip / D_SPACE.CMD next >
OS/2 REXX Batch file  |  1995-07-22  |  5KB  |  120 lines

  1. /* A REXX Script for AdeptXBBS, this script produces information about
  2.    drives installed in your System.
  3.  
  4.    It also produces a graph of available space on the drive letter.
  5.    The output is FULLY ansi/ascii compatable.
  6.  
  7.    As with all my utilities, this is freeware, but I would appreciate
  8.    feedback so I know that people are using them :-).
  9.  
  10.    I have included this source coz it only took me a couple of hours to do
  11.    it, and provides good examples of how to use the various REXX functions.
  12.  
  13.    Enjoy!.
  14.  
  15.           -Robert Stephens   ('Jewfish' in IRC #adept)
  16.  
  17.           Fido     : 3:622/421
  18.           Internet : ourjs@net-unix.newcastle.edu.au
  19.                                                                            */
  20. Arg Line
  21.  
  22. Call RxFuncAdd 'SysDriveInfo', 'RexxUtil', 'SysDriveInfo'
  23.  
  24. STRF_UCASE = X2D(00000001)      
  25. STRF_NOECHO = X2D(00000008)     
  26. STRF_MUSTHOT = X2D(00000100)    
  27.  
  28. Adept_Drive_Letter = VALUE('APATH',,'OS2ENVIRONMENT')
  29. If Adept_Drive_Letter = "" Then Do
  30.    Call AdeptPrint Line, "\r\n{FDSysop Warning!:\r\nThe 'APATH' environment variable isn't set, AdeptXBBSCallers will\r\nnot operate correctly without it."
  31.    Call AdeptHitReturn Line
  32.    Call AdeptPrint Line, '\r\n\r\nExiting ...'
  33.    Exit
  34. End
  35. Parse VAR Adept_Drive_Letter Drive_Letter ':'
  36. Adept_Drive_Letter = Drive_Letter":"
  37.  
  38. Temp = Stream(Adept_Drive_Letter'\ADEPT\MENUS\DRIVES.TXT','c','query exists')
  39. If Temp = "" Then Do
  40.    Call AdeptPrint Line, '\r\n\r\nThe File DRIVES.TXT has not been found in your Adept MENUS directory,\r\nplease check the Docs that came with AdeptDriveSpace\r\nThanks!.'
  41.    Call AdeptHitReturn Line
  42.    Exit
  43. End
  44. Available_Drives = LineIn(Adept_Drive_Letter'\ADEPT\MENUS\DRIVES.TXT')
  45. Do Until Position = 0
  46.    Position = Pos(':',Available_Drives)
  47.    If Position = 0 Then Leave
  48.    Temp_Drives = DelStr(Available_Drives,Position,1)
  49.    Available_Drives = Temp_Drives
  50. End
  51.  
  52. Drive = Word(Available_Drives,1)
  53. Number_Of_Drives = Words(Available_Drives)
  54.  
  55. Loopey:
  56. Info = SysDriveInfo(Drive)
  57. Drive_Letter = Left(Word(Info,1),2)
  58. Space_Free = Word(Info,2)
  59. Total_Space = Word(Info,3)
  60. Drive_Label = Left(Word(Info,4),10)
  61. Space_Used = Total_Space - Space_Free
  62.  
  63. Percent_Full = Trunc((((Total_Space - Space_Free) / Total_Space) * 100),1)
  64. Length = Trunc((50 * (Percent_Full / 100)),1)
  65. Parse Var Length Temp1 '.' Temp2
  66. If Temp2 >= 5 Then Temp1 = Temp1 + 1
  67. Length = Temp1
  68.  
  69. Graph_Line = Left(Copies('▀',Length),49,' ')
  70.  
  71. To_Do = Total_Space
  72. Call To_Convert_Out
  73. Total_Space = To_Do
  74.  
  75. To_Do = Space_Free
  76. Call To_Convert_Out
  77. Space_Free = To_Do
  78.  
  79. To_Do = Space_Used
  80. Call To_Convert_Out
  81. Space_Used = To_Do
  82.  
  83. Percent_Full = Left(Percent_Full'%',5)
  84. Call AdeptPrint Line, '\r\n\r\n{FA   ┌───────────────────────────────────────────────────────────────────────┐'
  85. Call AdeptPrint Line, '\r\n   │ {FGDrive 'Drive_Letter', Volume Label : 'Drive_Label'                                   {FA│'
  86. Call AdeptPrint Line, '\r\n   │                                                                       │'
  87. Call AdeptPrint Line, '\r\n   │             {FBTotal Storage   : 'Total_Space'                    {FA│'
  88. Call AdeptPrint Line, '\r\n   │             {FBBytes Used      : 'Space_Used'                    {FA│'
  89. Call AdeptPrint Line, '\r\n   │                                                                       │'
  90. Call AdeptPrint Line, '\r\n   │             {FGSpace Remaining : 'Space_Free'                    {FA│'
  91. Call AdeptPrint Line, '\r\n   │                                                                       │'
  92. Call AdeptPrint Line, '\r\n   │              {FD0%       20%       40%       60%       80%       100%    {FA│'
  93. Call AdeptPrint Line, '\r\n   ├──────────────┬─────────┬─────────┬─────────┬─────────┬─────────┬──────┤'
  94. Call AdeptPrint Line, '\r\n   │ {FCSpace Used :  {FF'Graph_Line'{FA│ {FG'Percent_Full'{FA│'
  95. Call AdeptPrint Line, '\r\n   └──────────────┴─────────┴─────────┴─────────┴─────────┴─────────┴──────┘{F8\r\n\r\n\'
  96.  
  97. Ask_Again:
  98. Call AdeptPrint Line, '\r\n{FCQ=Quit\r\n{FGChoose a Drive Letter to view ['Available_Drives'] : '
  99. Drive_To_Show = AdeptInput(Line,1,1,,STRF_UCASE+STRF_NOECHO+STRF_MUSTHOT,'',,,)
  100. If Drive_To_Show = '-2' Then Exit
  101. Check = WordPos(Drive_To_Show,Available_Drives)
  102. If Drive_To_Show = "Q" Then Exit
  103. If Check = 0 Then Do
  104.    Call AdeptPrint Line, '\r{FDDrive Letter NOT Available! -- Choose Again'
  105.    Signal Ask_Again
  106. End
  107. Drive = Drive_To_Show':'
  108. Signal Loopey
  109.  
  110. /******| Convert 123456789 to 123,456,789 |************/
  111. To_Convert_Out:
  112.    Str_Length = Length(To_Do)
  113.    Do While Str_Length >= 0
  114.       Str_Length = Str_Length - 3
  115.       If Str_Length <= 0 Then Leave
  116.       To_Do = Left(Insert(',',To_Do' bytes',Str_Length),20)
  117.    End
  118. Return
  119. /******| End of Conversion Routine |*******************/
  120.