JavaScript Editor js editor     Web development 



Main Page

Retrieves the number of bytes with the specified type that are available on the default or specified hard disk drive or volume.

DISKSPACE([cVolumeName [, nType]])

Parameters

cVolumeName


Specifies the name of the hard disk drive or volume for which the available space is returned. If you omit cVolumeName, the available space is returned for the default disk drive or volume.
nType


Specifies the type of hard disk space to retrieve. The following table lists the values for nType.

Value Description

1

Total amount of space on the hard disk drive.

2

Total amount of free space on the hard disk drive. (Default)

3

Total amount of free space available to the user associated with the calling thread.

Return Value

Numeric. DISKSPACE( ) returns the number of bytes with the type specified. If the hard disk is full, DISKSPACE( ) returns a value of 0 or -1. If an error occurs when reading the hard disk drive or volume, DISKSPACE( ) can also return a value of –1.

Note:
The return value of DISKSPACE(В ) might not be accurate for large network drives on some networks. Additionally, DISKSPACE(В ) may return -1 for certain long named directories on Windows 98.

Remarks

You can use DISKSPACE(В ) to determine if sufficient space is available to back up files or to execute commands such as SORT that require additional disk space for temporary work files.

You can specify the default disk drive or volume using the SET DEFAULT command.

Example

The following example uses DISKSPACE(В ) to determine whether sufficient disk space is available to perform a sort operation.

В Copy Code
*** Check DISKSPACE before sort ***
CLOSE DATABASES
OPEN DATABASE (HOME(2) + 'Data\testdata')
USE customer  && Opens Customer table

*** Get size of table header ***
gnTableHead = HEADER( )

*** Calculate size of table ***
gnFileSize = gnTableHead + (RECSIZE( ) * RECCOUNT( ) + 1)
IF DISKSPACE( ) > (gnFileSize * 3)
   WAIT WINDOW 'Sufficient diskspace to sort.'
ELSE
   WAIT WINDOW 'Insufficient diskspace. Sort cannot be done.'
ENDIF

See Also



JavaScript Editor js editor     Web development