• 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: Store Script Problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Store Script Problem


  • Subject: Re: Store Script Problem
  • From: Dave <email@hidden>
  • Date: Sun, 15 Nov 2015 19:14:05 +0000
  • X_v_e_cd: 744149c1c31ccabe2b9dfdf51191d5c1
  • X_v_r_cd: ec0288a3b7c85a365eabd8bf991d3f27

Hi,

I’m *really* confused over how best to achieve what I want to do.

I have an Objective-C App that calls methods in a .applescirpt file that is in my XCode project.

It’s very difficult to test this from Objective-C and I’d like to be able to load/compile whatever this script in another .appleScript file that references the file under test in Script Editor. For example:


OutlookHandler.applescript    			 — The file I want to test

OutlookTestHarness.applescript		—  Load/Compile/Whatever OutlookHandler.applescript and call handlers in it.

The OutlookHandler.applescript file:


--
--  OutlookHandler.applescript
--
use framework "Foundation"
use framework "OSAKit"
use scripting additions

script OutlookHandler
— Handlers
end OutlookHandler


The OutlookTestHarness.applescript:

--
--  OutlookTestHarness.applescript
—

—  Other handlers………..


on run
	set gLogFileRef to my LogFileOpen("AppleScriptTestHarnessLog.txt")

		set myHomeFolderPathName to my PathToMe()
		get my LogFileWrite(gLogFileRef, "PathToMe: " & return)

		--
		--	Load Outlook Handler
		--
		--my LogFileWrite(gLogFileRef, "Load Outlook Script: " & myTargetScriptFilePathName & return & return)

		set myScriptFileName to "BJAppleScriptHandlerOutlook"
		set myCompiledScriptPathPath to my CompileAndSaveFile(myHomeFolderPathName, myScriptFileName)
		if myCompiledScriptPathPath = missing value then
			get my LogFileClose(gLogFileRef)
			display dialog "Could not Compile Script: " & myCompiledScriptPathPath
			return "ScriptCompileError"
		end if

end run


OutlookTestHarness.applescript does not have any use statements in it and if I add them I get an error. Also it’s not in a script/end script block.

So given this setup, how can I do this? I just want to be able to call the same code as my Objective-C App calls but from the Script Editor.

Thanks a lot
All the Best
Dave


















> On 15 Nov 2015, at 06:02, Shane Stanley <email@hidden> wrote:
>
> On 15 Nov 2015, at 4:01 PM, Christopher Stone <email@hidden> wrote:
>>
>> If you look at store script it requires a script object as its direct object.
>>
>> A text script is NOT a script object.
>
> Ah, I didn't even notice that -- good point.
>
> But it's not going to make much difference, I don't think, because store script and ASObjC don't get along. Try adding use framework "Foundation" to the script you posted elsewhere, to see what I mean.
>
>> I suspect there is a method using ASObjC (but that'll have to wait for Shane).
>
> In this case Dave is writing a hybrid Objective-C/AS app, so he might as well just do it in Objective-C or C. But it can be done like this:
>
> use framework "Foundation"
> use framework "OSAKit"
>
> set sourceURL to current application's class "NSURL"'s fileURLWithPath:"path/to/file.applescript"
> set destURL to current application's class "NSURL"'s fileURLWithPath:"path/to/file.scpt"
> set theScript to current application's OSAScript's alloc()'s initWithContentsOfURL:sourceURL
> set theResult to theScript's compileAndReturnError:(missing value)
> if theResult as boolean then
> 	theScript's writeToURL:destURL ofType:(current application's OSAStorageScriptType) |error|:(missing value)
> end if
>
> --
> Shane Stanley <email@hidden>
> <www.macosxautomation.com/applescript/apps/>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> AppleScript-Users mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> Archives: http://lists.apple.com/archives/applescript-users
>
> This email sent to email@hidden


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden


  • Follow-Ups:
    • Re: Store Script Problem
      • From: Shane Stanley <email@hidden>
References: 
 >Store Script Problem (From: Dave <email@hidden>)
 >Re: Store Script Problem (From: Christopher Stone <email@hidden>)
 >Re: Store Script Problem (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: applescripting sub mailboxes in Mail
  • Next by Date: Re: Store Script Problem
  • Previous by thread: Re: Store Script Problem
  • Next by thread: Re: Store Script Problem
  • Index(es):
    • Date
    • Thread