
inifile="www-prod.ini"
inisection="DskSpace"
Sort=inireadpvt(inisection,"Sort",1,inifile)  
LTGRAY="192,192,192"  
GRAY="128,128,128"  
DKGRAY="64,64,64"  
GREEN="0,255,0"  
PURPLE="255,0,255"  
BLACK="0,0,0"  
WHITE="255,255,255"
BLUE="0,0,128"  
ErrorMode(@off)
D3COLORX=RegQueryValue(@REGCURRENT,"Control Panel\colors[ButtonFace]")
ErrorMode(@cancel)
if D3COLORX!=0 then D3COLOR=D3COLORX
else  D3COLOR="192,192,192"

;Debug(1)

;Changed to IntControl(29)
IntControl(29,@tab,0,0,0) ;Standardize on tabs so code runs in 16 and 32 bit  
BoxesUp("100,100,900,900",@Normal)  
Boxcolor(1,"192,192,192",4)  
boxdrawrect(1,"0,0,1000,1000",1)

;Initializing NoteId Box
Noteid=4  
rectNote="50,800,490,890"  
BoxNew(Noteid,rectNote,1)


BoxButtonDraw(1,1,"Alphabet","50,900,190,970")
BoxButtonDraw(1,2,"FreeSpace","200,900,340,970")
BoxButtonDraw(1,3,"TotalSize","350,900,490,970")  
BoxButtonDraw(1,4,"Exit","800,800,950,970")
NoteHeight=400  
rectNoteText="50,200,950,800"  
rectnoteline1="0,0,1000,0"  
rectNoteline2="1000,1000,1000,0"  
rectNoteLine3="0,1000,1000,1000"  
rectNoteLine4="0,0,0,1000"  
notepenwidth=20  
rectnoteline1b="40,150,960,150"  
rectNoteline2b="960,840,960,150"  
rectNoteLine3b="40,840,960,840"  
rectNoteLine4b="40,150,40,840"  
notepenwidthb=10  
BoxColor(Noteid,D3COLOR,0)         
BoxDrawRect(Noteid,"",2)  
BoxPen(Noteid,WHITE,notepenwidth)  
boxdrawline(Noteid,rectNoteLine1)  
boxdrawline(Noteid,rectNoteLine4)  
BoxPen(Noteid,GRAY,notepenwidth)  
boxdrawline(Noteid,rectNoteLine2)  
boxdrawline(Noteid,rectNoteLine3)  
BoxPen(Noteid,WHITE,notepenwidthb)  
boxdrawline(Noteid,rectNoteLine2b)  
boxdrawline(Noteid,rectNoteLine3b)  
BoxPen(Noteid,GRAY,notepenwidthb)  
boxdrawline(Noteid,rectNoteLine1b)  
boxdrawline(Noteid,rectNoteLine4b)  

;changed last param from 5 to 37 
BoxDrawText(Noteid,rectNoteText,"SORT BY:",1,37) 

BoxColor(1,BLUE,0)  
BoxDrawRect(1,"500,800,770,970",1)  
BoxTextColor(1,WHITE)  
BoxDrawText(1,"500,800,770,970","All measurements are in MegaBytes",1,21)  
BoxDataTag(1,"FRED")
 
   
while @true 
        ;debug(1)
        decimals(0)  
        Drives=Diskscan(6)  
        NumOfDrvs=ItemCount(Drives,@tab)  
        matrix=binaryalloc(NumOfDrvs*24)  
        
        for DIndex=1 to NumOfDrvs   
                 Drv=ItemExtract(DIndex,Drives,@tab)
                 Drv=StrReplace(Drv,":","")  
                 f=(DiskFree(Drv)/1048576.0)  
                 s=(DiskSize(Drv)/1048576.0)  
                 binarypokestr (matrix,(DIndex-1)*24,Drv)  
                 binarypokeflt(matrix,(DIndex-1)*24+8,f)  
                 binarypokeflt(matrix,(DIndex-1)*24+16,s)  
        next  
           
        binarysort(matrix,24,16,8,@descending|@float8)  
        biggest=binarypeekflt(matrix,16)  
        switch sort       ;(alphabet =1 Freespace=2 Totalsize=3)  
                case 1  
                 binarysort(matrix,24,0,8,@ascending) 
                 Break  
                case 2  
                 binarysort(matrix,24,8,8,@descending|@float8)   
                 Break  
                case 3  
                 binarysort(matrix,24,16,8,@descending|@float8)  
                 Break  
        EndSwitch  
        If NumOfDrvs>6   
                mult=350/biggest  
                Vert=60  
                Thick=25  
        else  
                mult=850/biggest  
                tTab=50  
                Vert=120  
                Thick=50  
        endif  
        ;Debug(1)  
        for ai= 1 to min(NumOfDrvs,26)  
               
             if ai>13  
                  a=ai-13   
                  tTab=520  
             else  
                  a=ai  
                  tTab=50  
             endif  
                  
                ;       Size  
                size=binarypeekflt(matrix,(ai*24)-8)  
                Boxcolor (1,PURPLE,0)  
                Muscle=strcat(tTab,",",a*Vert,",",(size*mult)+tTab,",",(a*Vert)+Thick)  
                BoxDrawRect(1,muscle,1)  
                boxtextcolor(1,PURPLE)  
                sinew=strcat((size*mult)+tTab,",",(a*vert),",",(size*mult)+tTab,",",(a*vert)+thick)   
                boxdrawtext(1,sinew,"%size% total",@false,0)  
                ;       Free  
                free=binarypeekflt(matrix,(ai*24)-16)  
                Boxcolor (1,GREEN,0)  
                bone=strcat(tTab,",",a*Vert,",",(free*mult)+tTab,",",(a*Vert)+Thick)  
                BoxDrawRect(1,bone,1)  
                marrow=strcat(tTab,",",(a*vert)+Thick+30,",",(size*mult)+tTab,",",(a*vert)+thick)   
                boxtextcolor(1,GREEN)  
                boxdrawtext(1,marrow,"%free% free",@false,0)  
                ;        Name  
                name=binarypeekstr (matrix,(ai*24)-24,1)  
                sinew=strcat(tTab-30,",",a*Vert,",",tTab,",",a*(Vert+Thick))  
                boxtextcolor(1,D3COLOR)  
                boxdrawtext(1,sinew,"%name%:",@false,0)  
          
        next ai
        ; debug(1)  
        BoxButtonWait()  
        if BoxButtonStat(1,4)==1 then break
        If BoxButtonStat(1,1)==1 then sort=1  
        If BoxButtonStat(1,2)==1 then sort=2  
        If BoxButtonStat(1,3)==1 then sort=3
        BoxDataClear(1,"FRED")  
        BoxUpdates(1,3) 
end while
iniwritepvt(inisection,"Sort",Sort,inifile)
exit  