home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a013 / 1.ddi / SAMPLES.EXE / T_DISKS.PRG < prev    next >
Encoding:
Text File  |  1991-01-25  |  2.4 KB  |  84 lines

  1. *****************************************************************
  2. * TEST program for ------- DISKSIZE, DISKTEST, SETINT24, GETINT24
  3. *                          FILE = T_DISKS.PRG
  4. *****************************************************************
  5. *
  6. * Copyright(c) 1991 -- James Occhiogrosso
  7.  
  8. # include "setcurs.ch"
  9. # include "inkey.ch"
  10.  
  11. LOCAL disk_drive := ' ', disk_error:= disk_num := keypress := 0,;
  12.       old_cursor := SETCURSOR()
  13.  
  14. INITGLOBAL()
  15. SETCOLOR(colstd)
  16. CLEAR
  17.  
  18. DO WHILE keypress != K_ESC
  19.  
  20.     @ 10, 20 SAY 'Enter letter for disk drive to test ...... ' ;
  21.              GET disk_drive PICTURE '!' VALID !EMPTY(disk_drive)
  22.  
  23.     READ
  24.  
  25.     * Turn off the cursor
  26.     SETCURSOR(SC_NONE)
  27.  
  28.     * Test the disk specified by the value of "disk_drive"
  29.     disk_error = DISKTEST(disk_drive)
  30.  
  31.     IF disk_error != 0
  32.         * An error occurred, display error message
  33.         DO CASE
  34.             CASE disk_error = 1
  35.                 @ 12, 20 SAY 'Disk in Drive ' + disk_drive + ;
  36.                              ' is write protected.'
  37.  
  38.             CASE disk_error = 3
  39.                 @ 12, 20 SAY 'Drive ' + disk_drive + ;
  40.                              ' is not ready.'
  41.  
  42.             CASE disk_error = 13
  43.                 @ 12, 20 SAY 'Disk in Drive ' + disk_drive + ;
  44.                              ' is not formatted.'
  45.  
  46.             CASE disk_error = -1
  47.                 @ 12, 20 SAY 'Drive ' + disk_drive +  ;
  48.                              ' is not a valid drive.'
  49.         ENDCASE
  50.  
  51.     ELSE
  52.  
  53.         @ 12, 20 SAY 'Drive ' + disk_drive + ' is ready. '
  54.  
  55.         * Note that Clipper DISKSPACE and Developer's Library
  56.         * DISKSIZE use numeric values for the disk argument.
  57.         * The drive letter is translated to a number (A=1, B=2, 
  58.         * etc.) before calling either function. This is done by
  59.         * subtracting 64 from its ASCII equivalent.
  60.  
  61.         disk_num = ASC(disk_drive) - 64
  62.  
  63.         * Display total disk size and free space.
  64.  
  65.         @ 13, 20 SAY 'Formatted size of this disk is = ' + ;
  66.                  LTRIM(STR(DISKSIZE(disk_num))) + ' bytes.'
  67.  
  68.         @ 14, 20 SAY 'It has ' + LTRIM(STR(DISKSPACE(disk_num)));
  69.                        + ' bytes free.'
  70.  
  71.     ENDIF
  72.  
  73.     * Reset the cursor and display message
  74.     SETCURSOR(old_cursor)
  75.     @ 17, 20 SAY 'Press any key to loop or Esc to exit.'
  76.     keypress = INKEY(0)
  77.     @ 12, 20 CLEAR TO 17, 70
  78.  
  79. ENDDO
  80.  
  81. RETURN
  82.  
  83.  
  84.