Simple question (from a simple person)

This forum is for eXpress++ general support.
Post Reply
Message
Author
BruceN
Posts: 280
Joined: Thu Jan 28, 2010 7:46 am
Location: Slidell, LA

Simple question (from a simple person)

#1 Post by BruceN »

I need to get the size of all files of a type (say, *.dbf) in a folder.

I can easily write a function that goes thru the file list, but it seems to me there would be an existing function that does it... but i can't find it.

thanks
There are only 10 kinds of people - those who understand binary and those who don't :)

User avatar
RDalzell
Posts: 205
Joined: Thu Jan 28, 2010 6:57 am
Location: Alsip, Illinois USA

Re: Simple question (from a simple person)

#2 Post by RDalzell »

Bruce,

From the Alaska docs for function directory()

Code: Select all

#include "Directry.ch" 
 
PROCEDURE Main 
  LOCAL aDbfFiles := Directory("*.DBF") 
  LOCAL nCount    := Len(aDbfFiles) 
  LOCAL n, nSum 
 
  nSum := 0 
 
  FOR n:= 1 TO nCount 
    nSum += aDbfFiles[ n, F_SIZE ] 
  NEXT 
 
  ? nCount, "DBF files occupying", nSum, "Bytes" 

RETURN 

BruceN
Posts: 280
Joined: Thu Jan 28, 2010 7:46 am
Location: Slidell, LA

Re: Simple question (from a simple person)

#3 Post by BruceN »

thanks...

i could have done something similar (although not quite as slick). I was hoping there as a function (perhaps something like DirSize(*.dbf) ) that would do it automatically, but I guess not.
There are only 10 kinds of people - those who understand binary and those who don't :)

bwolfsohn
Posts: 649
Joined: Thu Jan 28, 2010 7:07 am
Location: Alachua, Florida USA
Contact:

Re: Simple question (from a simple person)

#4 Post by bwolfsohn »

bruce,

simply change the first 2 lines of the code to:

function dirsize(aMask)
LOCAL aDbfFiles := Directory(aMask)

and the lst 2 to:

// ? nCount, "DBF files occupying", nSum, "Bytes"

RETURN(nSum)

and you have it..

dirsize("*.dbf")
Brian Wolfsohn
Retired and traveling around the country to music festivals in my RV.
OOPS.. Corona Virus, so NOT traveling right now...
http://www.breadmanrises.com
FB travel group: The Breadman Rises

BruceN
Posts: 280
Joined: Thu Jan 28, 2010 7:46 am
Location: Slidell, LA

Re: Simple question (from a simple person)

#5 Post by BruceN »

That's basically what I did. The aFiles[ n, F_SIZE ] didn't work, so I changed things to:

FUNCTION FileTypeSize(Ftype)
LOCAL aFiles := Directory(Ftype)
LOCAL nCount := Len(aFiles)
LOCAL n, nSum:=0

FOR n:= 1 TO nCount
nSum += aFiles[ n, 2]
NEXT

RETURN nSum
There are only 10 kinds of people - those who understand binary and those who don't :)

Post Reply