• 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 data between Applescript and ObjC
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Passing data between Applescript and ObjC


  • Subject: Re: Passing data between Applescript and ObjC
  • From: Charilaos Skiadas <email@hidden>
  • Date: Mon, 21 Mar 2005 14:45:47 -0600

So, you just want to call applescripts from within ObjC? If so, have you looked at the NSAppleScript class?

Haris
On Mar 21, 2005, at 1:48 PM, Don Thompson wrote:

Here is a really simple piece of code to communicate between AS and ObjC. The code will pass information from ObjC to AS; however, I am missing something for the return trip. Any help is greatly appreciated!!

OBJECTIVE C


#import <mach-o/dyld.h> #import <Cocoa/Cocoa.h>

extern int NSApplicationMain(int argc, const char *argv[]);
NSString *x;

int main(int argc, const char *argv[])
{
	x = @"hi don";

	if (NSIsSymbolNameDefined("_ASKInitialize"))
	{
		NSSymbol *symbol = NSLookupAndBindSymbol("_ASKInitialize");
		if (symbol)
		{
			void (*initializeASKFunc)(void) = NSAddressOfSymbol(symbol);
			if (initializeASKFunc)
			{
				initializeASKFunc();
			}
		}
	}

    return NSApplicationMain(argc, argv);
}

@implementation NSApplication (ASKAMultiLanguage)
- (NSString *) returnMyX {
	return x;
}
// This method is never called
+ (void) takeFromScript:(NSString *)value {
	char buffer[200];
	[value getCString : buffer];
	printf("takeFromScript: \'%s\'\n", buffer);
}
@end

APPLESCRIPT

global x
on clicked theObject

	set y to call method "returnMyX"
	beep
	display dialog "Hello World"
	display dialog y

	set u to "yurka"
	call method "takeFromScript" with parameter u

end clicked


Thanks

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


This email sent to email@hidden

_______________________________________________ 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
References: 
 >Passing data between Applescript and ObjC (From: Don Thompson <email@hidden>)

  • Prev by Date: Re: Can't open a sheet on a panel twice (Modified by OS) (apologies)
  • Next by Date: Re: Access iTunes Playlists / tracks via Cocoa
  • Previous by thread: Passing data between Applescript and ObjC
  • Next by thread: Re: Can't open a sheet on a panel twice (Modified by OS) (apologies)
  • Index(es):
    • Date
    • Thread