• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: passing parameters to an AppleScript from Objective-C
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: passing parameters to an AppleScript from Objective-C


  • Subject: Re: passing parameters to an AppleScript from Objective-C
  • From: Finlay Dobbie <email@hidden>
  • Date: Wed, 16 Feb 2005 18:46:26 +0000

On Wed, 16 Feb 2005 12:17:40 -0500, Daniel Morrow <email@hidden> wrote:
> I have an app which includes an AppleScript file. I want to load and
> execute the script, but also pass a parameter to it.

You might find the following useful:

@implementation NSAppleScript(FDExtensions)

- (NSAppleEventDescriptor *)executeHandler:(NSString *)handlerName
parameters:(NSAppleEventDescriptor *)parameters error:(NSDictionary
**)errorInfo {
	ProcessSerialNumber psn = { 0, kCurrentProcess };
	NSAppleEventDescriptor *target =
		[NSAppleEventDescriptor descriptorWithDescriptorType:typeProcessSerialNumber
													   bytes:&psn
													  length:sizeof(ProcessSerialNumber)];

	NSAppleEventDescriptor *event =
		[NSAppleEventDescriptor appleEventWithEventClass:kASAppleScriptSuite
												 eventID:kASSubroutineEvent
										targetDescriptor:target
												returnID:kAutoGenerateReturnID
										   transactionID:kAnyTransactionID];
	NSAppleEventDescriptor *handler = [NSAppleEventDescriptor
descriptorWithString:[handlerName lowercaseString]];
	[event setParamDescriptor:handler forKeyword:keyASSubroutineName];

	if (parameters != nil) [event setParamDescriptor:parameters
forKeyword:keyDirectObject];

	return [self executeAppleEvent:event error:errorInfo];
}

@end

 -- Finlay
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: passing parameters to an AppleScript from Objective-C
      • From: Ken Ferry <email@hidden>
References: 
 >Formatting integer value (From: RenĂ© Korthaus <email@hidden>)
 >Re: Formatting integer value (From: Charlton Wilbur <email@hidden>)
 >Re: Formatting integer value (From: Andreas Mayer <email@hidden>)
 >OT: "metric" time (From: Andreas Mayer <email@hidden>)
 >Re: OT: "metric" time (From: Shawn Erickson <email@hidden>)
 >passing parameters to an AppleScript from Objective-C (From: Daniel Morrow <email@hidden>)

  • Prev by Date: Re: size of contextual menu items
  • Next by Date: Creating NSViews with code.
  • Previous by thread: passing parameters to an AppleScript from Objective-C
  • Next by thread: Re: passing parameters to an AppleScript from Objective-C
  • Index(es):
    • Date
    • Thread