Obtaining the size of a file
    Richard Gaskin 
    ambassador at fourthworld.com
       
    Fri Apr 20 22:02:38 EDT 2007
    
    
  
John Craig wrote:
> Richard Gaskin wrote:
>> John Craig wrote:
>>> Does anyone know of a native rev. method to obtain the size of a file 
>>> without using shell or 'the detailed files'?
>>
>> What's the objection to using 'the detailed files'?
>>
>> It was added to the language specifically to provide what you're 
>> looking for.
>>
> It's clumsy and long winded.
Revolution allows you to write your own custom commands and functions, 
so you can get the exact info you want in a call as simple as:
    get FileSize(pFilePath)
Since it only takes a minute to write the dozen or so lines needed, I'll 
go ahead and do that for you:
function FileSize pPath
   set the itemdel to "/"
   put urlEncode(last item of pPath) into tShortFileName
   delete last item of pPath
   put the directory into tSaveDir
   set the directory to pPath
   put the detailed files into tFiles
   set the directory to tSaveDir
   set the itemdel to comma
   put lineoffset( cr&tShortFileName&comma, cr&tFiles) into tLineNum
   if tLineNum > 0 then
     put line tLineNum of tFiles into tLine
     return item 2 of tLine + item 3 of tLine
   end if
end FileSize
Now you can drop than handy function into a library somewhere and use it 
whenever you need it.
	
-- 
  Richard Gaskin
  Fourth World Media Corporation
  ___________________________________________________________
  Ambassador at FourthWorld.com       http://www.FourthWorld.com
    
    
More information about the use-livecode
mailing list