From: Christiaan H. <ho...@us...> - 2004-11-29 22:19:16
|
Update of /cvsroot/bibdesk/bibdesk/Scripting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8161/Scripting Modified Files: BibItem+Scripting.m Log Message: Adding check to allow setting BibTeX string in AppleScript only at initialization. Index: BibItem+Scripting.m =================================================================== RCS file: /cvsroot/bibdesk/bibdesk/Scripting/BibItem+Scripting.m,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** BibItem+Scripting.m 28 Nov 2004 22:02:46 -0000 1.8 --- BibItem+Scripting.m 29 Nov 2004 22:19:02 -0000 1.9 *************** *** 213,216 **** --- 213,229 ---- NSString *texstr = [[BDSKConverter sharedConverter] stringByTeXifyingString:btString]; NSData *data = [texstr dataUsingEncoding:NSUTF8StringEncoding]; + NSScriptCommand * cmd = [NSScriptCommand currentCommand]; + + NSEnumerator *fnEnum = [pubFields keyEnumerator]; + NSString *fn; + while (fn = [fnEnum nextObject]) { + if (!([[self valueOfField:fn] isEqualToString:@""] || [fn isEqualToString:@"Date-Modified"] || [fn isEqualToString:@"Date-Added"])) { + if (cmd) { + [cmd setScriptErrorNumber:NSReceiversCantHandleCommandScriptError]; + [cmd setScriptErrorString:[NSString stringWithFormat:NSLocalizedString(@"Cannot set BibTeX string after initialization.",@"Cannot set BibTeX string after initialization.")]]; + } + return; + } + } BOOL hadProblems = NO; *************** *** 218,224 **** // try to do some error handling for AppleScript ! NSScriptCommand * cmd = [NSScriptCommand currentCommand]; ! if(hadProblems && cmd) { ! [cmd setScriptErrorString:[NSString stringWithFormat:NSLocalizedString(@"Bibdesk failed to process the BibTeX entry %@. It may be malformed.",@"Bibdesk failed to process the BibTeX entry %@. It may be malformed."), btString]]; return; } --- 231,239 ---- // try to do some error handling for AppleScript ! if(hadProblems) { ! if (cmd) { ! [cmd setScriptErrorNumber:NSInternalScriptError]; ! [cmd setScriptErrorString:[NSString stringWithFormat:NSLocalizedString(@"Bibdesk failed to process the BibTeX entry %@. It may be malformed.",@"Bibdesk failed to process the BibTeX entry %@. It may be malformed."), btString]]; ! } return; } |