DSpace subroutine

Returns the amount of total space and available space (in bytes), for a particular drive.

DSpace(Drive, Unused, FreeClusters, SectorsPerCluster, BytesPerSector, TotalClusters)

The DSpace subroutine has the following parameters.

ParameterDescription
DriveThe physical drive letter for which the information will be returned. Pass the actual letter (such as C), omitting the colon.
UnusedIf available space is less than 2 gigabytes, returns the available space, otherwise is unused. For reliable results, see the example below.
FreeClustersNumber of free clusters. To get total available space, multiply by SectorsPerCluster * BytesPerSector.
SectorsPerClusterNumber of sectors per cluster.
BytesPerSectorNumber of bytes per sector.
TotalClustersNumber of total clusters. To get total space, multiply by SectorsPerCluster * BytesPerSector
 
/* running DSpace from System Editor Command Line

   Compile this function

*/

 

function ShowDiskSize(Disk)

declare subroutine DSpace

NotUsed           = 0    ;* available space in bytes (if <2GB)

FreeClusters      = 0

SectorsPerCluster = 0

BytesPerSector    = 0

TotalClusters     = 0

DSpace(Disk, NotUsed, FreeClusters, SectorsPerCluster, BytesPerSector, TotalClusters)

AvailableBytes = FreeClusters  * SectorsPerCluster * BytesPerSector

TotalBytes     = TotalClusters * SectorsPerCluster * BytesPerSector

return AvailableBytes: " of ": TotalBytes

From the System Editor Command Line, to display the available space on Drive C, type the following:

Run ShowDiskSize "C"

Example 2 : calling DSpace directly

declare subroutine DSpace

Disk              = "C"  ;* the drive letter

NotUsed           = 0    ;* available space in bytes (if <2GB)

FreeClusters      = 0

SectorsPerCluster = 0

BytesPerSector    = 0

TotalClusters     = 0

DSpace(Disk, NotUsed, FreeClusters, SectorsPerCluster, BytesPerSector, TotalClusters)

AvailableBytes = FreeClusters  * SectorsPerCluster * BytesPerSector

TotalBytes     = TotalClusters * SectorsPerCluster * BytesPerSector
 
  • guides/programming/programmers_reference_manual/dspace.txt
  • Last modified: 2024/06/19 20:20
  • by 127.0.0.1