DSpace subroutine
Description
Returns the amount of total space and available space (in bytes), for a particular drive.
Syntax
DSpace(Drive, Unused, FreeClusters, SectorsPerCluster, BytesPerSector, TotalClusters)
Parameters
The DSpace subroutine has the following parameters.
Parameter | Description | |
---|---|---|
Drive | The physical drive letter for which the information will be returned. Pass the actual letter (such as C), omitting the colon. | |
Unused | If available space is less than 2 gigabytes, returns the available space, otherwise is unused. For reliable results, see the example below. | |
FreeClusters | Number of free clusters. To get total available space, multiply by SectorsPerCluster * BytesPerSector. | |
SectorsPerCluster | Number of sectors per cluster. | |
BytesPerSector | Number of bytes per sector. | |
TotalClusters | Number of total clusters. To get total space, multiply by SectorsPerCluster * BytesPerSector |
Examples
/* 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