Title: Re: Entourage Just Works, always
on 6/1/05 11:20 PM, Beth Rosengard at [EMAIL PROTECTED] wrote:

>
> P.S.  Does anyone know how to find out how many items are in a database, if
> that’s even possible??

I have used this, it tends to error on first run, then work on second run:
-- this is the line that kicks it all off and starts the recursion
-- see how it works in the 'countTheMail' routine later
set theCounts to countTheMail(application "Microsoft Entourage")

-- Now, find out where the data is

tell application "Microsoft Entourage"
    set theName to name of current identity
   set theDataFolder to ((path to MUD as text) & "Office 2004 Identities:" & theName)
end tell
-- and get it's size from the finder
tell application "Finder" to set diskUse to physical size of item theDataFolder
--convert bytes to megabytes
set theSize to (diskUse / 1048576 + 0.5) div 1

-- We got the info from the routines below, now we display it
-- and record the button pressed in the dialog box
set buttonPushed to display dialog "Identity \"" & theName & "\"" & return & ¬
    "You have " & commafy(item 2 of theCounts) of me & " mailfolders containing " & commafy(item 1 of theCounts) of me & " messages" & return & ¬
    "The mail occupies " & theSize & "mb of disk space." buttons {"Copy…", "O.K."} ¬
    default button 2
if the button returned of buttonPushed is not "O.K." then
   set the clipboard to "Identity: " & theName & return & ¬
        "Folders: " & commafy(item 2 of theCounts) of me & return ¬
        & "Messages: " & commafy(item 1 of theCounts) of me & return ¬
        & "Data Folder Size: " & theSize & "mb" & return
end
if


on countTheMail(theMailFolder)
    -- this is the main recursive loop. Remember that all variables
   -- used here are LOCAL and are reset each time the routine is entered
   -- this routine is entered once for each mail folder found
   tell application "Microsoft Entourage"
        set theFolders to every folder of theMailFolder
       set mailcount to 0
        -- count the folders at this level
       set folderCount to count theFolders
       repeat with aFolder in theFolders
           -- and for every folder, count the messages
           set mailcount to mailcount + (count every message of aFolder)
            -- do we need to go down another level?
           if every folder of aFolder is not {} then
               -- yes we do, so...
               -- ...recursively call this routine, using this folder as the start point :)
               set temp to my countTheMail(aFolder)
                -- and update folder & message counts
               set mailcount to mailcount + (item 1 of temp)
                set folderCount to folderCount + (item 2 of temp)
            end if
           -- next folder at current level
       end repeat
   end tell
   -- now, send the answer back up the line
   return {mailcount, folderCount}
end countTheMail

on commafy(theNum)
    -- Another recursive routine that converts an integer to a western formatted
   -- number with commas between the 'thousand' groupings
   if theNum > 999 then return (commafy(theNum div 1000) & "," & text -3 thru -1 of ("00" & ((theNum mod 1000) as text)))
    return theNum as text
end
commafy

--
-------------------------------------------------------------
Scott Haneda                                Tel: 415.898.2602
<http://www.newgeo.com>                     Novato, CA U.S.A.

Reply via email to