I don't see a better list for Scripting Bridge — referrals welcome. I am looking for a local-folder element in the Entourage application. If there is none, I want to create it. This works fine on my 10.6 installation, but not on my customer's 10.5. Both machines are Intel, running the same version of Entourage.
Here is the relevant method, in a category of SBObject. My customer swears he has a local folder named "Archive" already. The log output is as shown in the comments. - (EntourageFolder *) archiveFolder: (BOOL) createIfNeeded { NSAssert([self isKindOfClass: [gApp classForScriptingClass: @"application"]], @"Looking for archive from something other than Entourage itself"); EntourageApplication * app = (EntourageApplication *) self; EntourageFolder * folder = [[app folders] objectWithName: kArchiveFolderName]; if ([folder exists]) { #if DEBUG_CREATE_10_5 NSLog(@"archiveFolder: folder does exist."); // Does not print #endif return folder; } #if DEBUG_CREATE_10_5 else NSLog(@"archiveFolder: folder does not exist."); // Prints #endif if (! createIfNeeded) return nil; Class folderClass = [app classForScriptingClass: @"folder"]; #if DEBUG_CREATE_10_5 NSLog(@"archiveFolder: creating Archive folder."); #endif folder = [[folderClass alloc] initWithProperties: [NSDictionary dictionaryWithObject: kArchiveFolderName forKey: @"name"]]; #if DEBUG_CREATE_10_5 NSLog(@"archiveFolder: initialized Archive folder (%@)", folder); // Prints as future object @try { #endif [[app folders] addObject: folder]; #if DEBUG_CREATE_10_5 } @catch (NSException * e) { NSLog(@"Folder addObject archiveFolder: error %...@\nreason: %...@\nuserinfo: %@", e.name, e.reason, e.userInfo); /* LOGS: Folder addObject archiveFolder: error NSGenericException Reason: Apple event returned an error. Event = 'core'\'crel'{ 'kocl':'cFld', 'insh':'insl'{ 'kobj':'obj '{ 'want':'cFld', 'from':'null'(), 'form':'indx', 'seld':'abso'($206C6C61$) }, 'kpos':'end ' }, 'prdt':{ 'pnam':'utxt'("Archive") } } Error info = { ErrorNumber = -10014; } UserInfo: { ErrorNumber = -10014; } */ } NSLog(@"archiveFolder: inserted Archive folder (%@)", folder); // Prints as future object #endif return [folder autorelease]; } I know Scripting Bridge @throws for AppleScript errors only on 10.5. It's for debugging only. Error -10014 is errAENotASingleObject, indicating that addObject: (actually crel, create element) went to more than one object. It _looks_ like the location is something like "end of ALL folders," but I don't know why the form is 'indx'. That 'abso' of $206C6C61$ (' lla') is an endian-swap of the 'all ' constant. It worries me. Setting NSScriptingDebugLogLevel to 1 in the global, Entourage, and my-application defaults had no effect at all on my 10.6 machine. So I can't see whether the 10.6 core/crel is different. I'd appreciate any help at all. — F _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com