While exploring Applescript Objective C (thanks Shane Stanley), I have found that a large number of Objective C methods have an option parameter. I have no problem supplying one of the option constants, but have been unable to find a way of doing a bitwise OR with multiple constants using applescript.
Does anyone know a way to do this?
Example handler:
on replaceItemAtPath:psxDestPathString withItemAtURL:psxSrcPathString
-- This handler moves Src contents, replacing Dest contents, keeping Dest name, with backup of Dest. Src path is destroyed.
-- uses the following convenience properties
-- property thisapp : current application
-- property NSString : class "NSString"
-- property NSURL : class "NSURL"
-- property NSFileManager : class "NSFileManager"
-- References
-- NSFileManager instance method
-- - replaceItemAtURL:withItemAtURL:backupItemName:options:resultingItemURL:error:
-- NSURL class method
-- + (NSURL *)fileURLWithPath:(NSString *)path
-- Shove all the pieces into obj-C scope
set buNameString to (NSString's stringWithString:"Backup.bu")
set psxDestPathString to (NSString's stringWithString:psxDestPathString)
set psxSrcPathString to (NSString's stringWithString:psxSrcPathString)
-- Expand paths
set psxDestPathString to (psxDestPathString's stringByExpandingTildeInPath)
set psxSrcPathString to (psxSrcPathString's stringByExpandingTildeInPath)
-- Convert NSStrings to NSURLs
set psxDestPathURL to NSURL's fileURLWithPath:psxDestPathString
set psxSrcPathURL to NSURL's fileURLWithPath:psxSrcPathString
-- option 1: thisapp's NSFileManagerItemReplacementUsingNewMetadataOnly
-- option 2: thisapp's NSFileManagerItemReplacementWithoutDeletingBackupItem
-- Can't figure this out: set bitwiseORComponents to (option 1 | option 2) <------------------------------<<
-- works fine with one constant
set replaceOptions to thisapp's NSFileManagerItemReplacementWithoutDeletingBackupItem
set response to (NSFileManager's defaultManager's replaceItemAtURL:psxDestPathURL withItemAtURL:psxSrcPathURL backupItemName:buNameString options:replaceOptions resultingItemURL:psxDestPathURL |error|:(missing value))
return response
end replaceItemAtPath:withItemAtURL: