The following example uses DISKSPACE( ) to determine whether sufficient disk space is available to perform a sort.
*** 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