Hi There again,
Another question: is there a function like DISKSPACE() which returns the CAPACTITY of a disk (instead of FREE space)?
This in order to calculate percentage used.
Thx,
Serge
function like DISKSPACE() question
Moderator: Rathinagiri
- serge_girard
- Posts: 3173
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
function like DISKSPACE() question
There's nothing you can do that can't be done...
Re: function like DISKSPACE() question
Hi,
Yes, it is the function HB_DISKSPACE with parameter HB_DISK_TOTAL.
Please be so kind to try the following simple sample from MiniGui Ex distribution:
Hope that helps.
Yes, it is the function HB_DISKSPACE with parameter HB_DISK_TOTAL.
Please be so kind to try the following simple sample from MiniGui Ex distribution:
Code: Select all
#include "minigui.ch"
#include "fileio.ch"
PROCEDURE Main
LOCAL cDisk := CurDrive() + ":\"
SET DECIMALS TO
DEFINE WINDOW Win_1 ;
AT 0,0 WIDTH 220 HEIGHT 240 ;
TITLE cDisk ;
ICON "HARD" ;
MAIN NOMAXIMIZE NOSIZE ;
ON INIT ShowPie(cDisk)
ON KEY ESCAPE ACTION Win_1.Release
END WINDOW
Win_1.Center
Win_1.Activate
RETURN
PROCEDURE ShowPie( cDisk )
LOCAL iFree := HB_DISKSPACE(cDisk, HB_DISK_FREE) / 1024
LOCAL iTotal:= HB_DISKSPACE(cDisk, HB_DISK_TOTAL) / 1024
LOCAL iUsed := iTotal - iFree, lFlag := iUsed > iFree
DRAW GRAPH IN WINDOW Win_1 ;
AT 10,10 ;
TO 200,200 ;
TITLE "" ;
TYPE PIE ;
SERIES { iUsed, iFree } ;
DEPTH 10 ;
SERIENAMES { "Espacio utilizado", "Espacio libre" } ;
COLORS { {0,0,255}, {255,0,255} } ;
3DVIEW SHOWLEGENDS
DRAW TEXT IN WINDOW Win_1 ;
AT IF(lFlag, 60, 90), 84 ;
VALUE "Libre "+Ltrim(Str((iFree/iTotal*100)))+"%" ;
FONT "MS Sans Serif" SIZE 9 ;
FONTCOLOR IF(lFlag, WHITE, BLACK) ;
TRANSPARENT
RETURN
Kind Regards,
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
- serge_girard
- Posts: 3173
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: function like DISKSPACE() question
Great !!
Execpt CurDrive I had to change to hb_CurDrive.
DRAW TEXT gives a compile error, but the PIE is exactly what I need.
Thx !
Serge
Execpt CurDrive I had to change to hb_CurDrive.
DRAW TEXT gives a compile error, but the PIE is exactly what I need.
Thx !
Serge
There's nothing you can do that can't be done...
-
- Posts: 190
- Joined: Wed Jan 06, 2010 5:39 pm
Re: function like DISKSPACE() question
I have made little changes to the program in order to be compiled by HMG.
Enjoy it#include "hmg.ch"
#include "fileio.ch"
PROCEDURE Main
LOCAL cDisk := hb_CurDrive() + ":\"
SET DECIMALS TO
DEFINE WINDOW Win_1 ;
AT 0,0 WIDTH 240 HEIGHT 260 ;
TITLE "Disk "+cDisk ;
MAIN NOMAXIMIZE NOSIZE ;
ON INIT ShowPie(cDisk)
ON KEY ESCAPE ACTION Win_1.Release
END WINDOW
Win_1.Center
Win_1.Activate
RETURN
PROCEDURE ShowPie( cDisk )
LOCAL iFree := INT(HB_DISKSPACE(cDisk, HB_DISK_FREE) / 1024 /1000000)
LOCAL iTotal:= INT(HB_DISKSPACE(cDisk, HB_DISK_TOTAL) / 1024 /1000000)
LOCAL iUsed := iTotal - iFree
DRAW GRAPH IN WINDOW Win_1 ;
AT 10,10 ;
TO 220,220 ;
TITLE "" ;
TYPE PIE ;
SERIES { iUsed, iFree } ;
DEPTH 10 ;
SERIENAMES { "Used space", "Free space " } ;
COLORS { {255,0,255}, {0,0,255} } ;
3DVIEW SHOWLEGENDS SHOWXVALUES
RETURN