Thread: AppleScript
View Single Post
  #5  
Old 04-11-2007, 05:54 PM
ShosMeister ShosMeister is offline
Registered User
 
Join Date: Apr 2007
Posts: 14
I'm not sure what you mean by the "normal way". I've done a very minimal amount of Apple Script and all of it was done by using other sample code and modifying it to fit my needs. For example, this is the code that I cobbled together from samples in Retrospect and FileMaker to log the actions of the backup:

Code:
on volumeEnd given VolumeName:theVolume, KBCopied:theKB, FileCount:theFileCount, DurationInSeconds:theDuration, BackupDate:theBackupDate, startDate:theStartDate, endDate:theEndDate, destinationName:theDestination, ClientName:theClient, zoneName:theZone, scriptName:theScript, backupTypeString:theBackupType, subvolumeDiskName:theDiskName, fileErrorCount:theFileErrorCount, volumeErrorCode:theVolumeError, volumeErrorMessage:theVolumeErrorMessage, activatorCodeString:theActivatorCode
	
	set gStorageSet to theDestination
	set gNumVolumesBackedup to gNumVolumesBackedup + 1
	if theVolumeError is not 0 or theFileErrorCount is not 0 then
		set gVolumeErrors to gVolumeErrors + 1
	end if
	
	if theDiskName is not "" then
		set theParent to "The Subvolume’s parent disk is \"" & theDiskName & "\"."
	else
		set theParent to ""
	end if
	set theDuration to secondsConverter(theDuration)
	
	if theVolumeError is 0 then
		set theSuccess to "successfully"
		set mySubject to "Retrospect: Success"
		set gBackUpReport to gBackUpReport & "Volume \"" & theVolume & "\" completed " & theSuccess & ¬
			", copying " & theFileCount & " files for " & theKB & " K with " & theFileErrorCount & ¬
			" errors." & return & return & "Script \"" & theScript & "\" finished copying volume \"" & ¬
			theVolume & "\" to destination \"" & theDestination & "\"." & return & return & "Duration: " & ¬
			theDuration & "." & return & return & lineDelimiter & return & return
	else
		set theSuccess to "with error " & theVolumeError & ": " & theVolumeErrorMessage
		set mySubject to "Retrospect: Error " & theVolumeError & ": " & theVolumeErrorMessage
		set gBackUpReport to gBackUpReport & "•Error•" & return & return & ¬
			"Volume \"" & theVolume & "\" completed " & theSuccess & "." & return & return & lineDelimiter & return & return
	end if
	
	-- Record the parameters for each volume in a new record in a database
	tell application "FileMaker Pro"
		tell document "Retrospect Database"
			create new record with data {theVolume, theKB, theFileCount, theDuration, theBackupDate as string, ¬
				theStartDate as string, theEndDate as string, theDestination, theClient, theZone, theScript, ¬
				theBackupType, theDiskName, theFileErrorCount, theVolumeError, theVolumeErrorMessage, theActivatorCode}
		end tell
	end tell
end volumeEnd
Reply With Quote