• 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: Getting the results out of Applescript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting the results out of Applescript


  • Subject: Re: Getting the results out of Applescript
  • From: Mike Abdullah <email@hidden>
  • Date: Sat, 7 Jan 2006 17:21:02 +0000

With a lot of experimentation, I have been able to get both integers and booleans to work. However, still every time I try to do

	[theResult stringValue]

I just get a large, random number. I've found plenty of examples on the Web using this stringValue method, but no mention of the problem I'm having.

So, please, surely someone out there must have some experience with this?

Many, many, thanks if anyone can solve the issue,
Mike A.

On 7 Jan 2006, at 13:12, Mike Abdullah wrote:

I am having difficulties trying to get an AppleScript to work with my app. Basically I have placed the script inside the resources folder of my app, and I have written code that will run the script no problem. However, I cannot figure out how to get the results of my script. The script (ideally) does something like this:

	return {value1:"foo1", value2: "foo2"}

This should (if I have understood things properly, correspond to an NSDictionary). So how do you actually access these results? I currently have the following code:

NSURL *scriptURL = [NSURL fileURLWithPath:
[[NSBundle mainBundle] pathForResource: @"theScript" ofType: @"scpt"]];


NSDictionary *theDict = [[NSDictionary alloc] init];

NSAppleEventDescriptor *desc;
NSAppleScript *theScript = [[NSAppleScript alloc] initWithContentsOfURL: scriptURL error: &theDict];
desc = [theScript executeAndReturnError: &theDict];

[theScript release];
[theDict release];


So, if I understand it, the values returned by the script are now stored in desc. However, how do I get them out? I see there is a method for getting string values, data, and one that looks like it probably does records and lists, button I cannot persuade it to work.

I also tried having the script simply do:

	return "foo"

and then did [desc stringValue] but all I got printed to the log was a sequence of numbers, which, bizzarley change each time the script is run - surely it should be the same result each time!
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40hotmail.com


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


  • Follow-Ups:
    • Re: Getting the results out of Applescript
      • From: Andy Armstrong <email@hidden>
    • Re: Getting the results out of Applescript
      • From: Andy Armstrong <email@hidden>
References: 
 >Getting the results out of Applescript (From: Mike Abdullah <email@hidden>)

  • Prev by Date: Re: one window with two documents
  • Next by Date: Re: one window with two documents
  • Previous by thread: Getting the results out of Applescript
  • Next by thread: Re: Getting the results out of Applescript
  • Index(es):
    • Date
    • Thread