Parallel processing 2 scripts

Hi McUsr,

I didn’t know how to do a clean install, so installed over straight from the apple store download. There are a few quirks. For now thing I can’t get Finder windows to open in new window by double clicking. I guess Apple will fix it on a update.

Trying to figure out how to call Shane’s cocoa handlers.

Edited: btw, your Tree app still works! :slight_smile: That’s good because ‘completely expanded’ is still not available.

Have a good day,
kel

What don’t you follow in my instructions? You save the library, then use its name in the use line of the calling script.

Hi Shane,

I’m going to reflow the instructions now that I’ve had a good rest.

Thanks,
kel

It works calling the Script Library! :slight_smile:

But I can’t get it to run the handler in the calling script:

use theLib : script "SpeechTest"
use scripting additions

theLib's startSaying:"Hello world, welcome to AppleScriptObjC" sender:me
set r to result
stringSpoken:1

on stringSpoken:theFlag
	if theFlag = 1 then
		log "The string was spoken"
	else
		log "Trouble at mill"
	end if
end stringSpoken:

Hello.

Glad it still works. :slight_smile:

Got it working!

use theLib : script "SpeechTest"
use scripting additions

theLib's startSaying:"Hello world, welcome to AppleScriptObjC" sender:me
my stringSpoken:1

on stringSpoken:theFlag
	if theFlag = 1 then
		log "The string was spoken"
	else
		log "Trouble at mill"
	end if
end stringSpoken:

It needed ‘my’. I guess the log called from the Library script won’t show in the ASE when called from the Library script:

on speechSynthesizer:anNSSpeechSynthesizer didFinishSpeaking:theFlag
	theSender's stringSpoken:(theFlag as integer)
end speechSynthesizer:didFinishSpeaking:

Need to check this out more.

Thanks a lot,
kel

It was working! added some beeps:

use theLib : script "SpeechTest"
use scripting additions

theLib's startSaying:"Hello world, welcome to AppleScriptObjC" sender:me

on stringSpoken:theFlag
	if theFlag = 1 then
		beep 3
		log "The string was spoken"
	else
		log "Trouble at mill"
	end if
end stringSpoken:

Bummer – I thought that was working. If you grab the demo version of my ASObjC Explorer for Mavericks, it shows in the Result pane there.

Hi Shane,

That’s ok because I hardly use ‘log’ anyway. A few well placed beeps and Vicki says a lot.

Thanks a lot,
kel

Hi Shane,

I’ve been getting bellow 0.02 secs. with your technique. Even with the feedback! I think that’s happening on a different thread or something. :cool:

Here’s the timing if anyone is interested:

use theLib : script "SpeechTest"
use scripting additions

run script (do shell script "python -c 'import time; print time.time()'") --dummy
set t1 to run script (do shell script "python -c 'import time; print time.time()'")
set t2 to run script (do shell script "python -c 'import time; print time.time()'")
set time_calib to t2 - t1
set t1 to run script (do shell script "python -c 'import time; print time.time()'")
--
theLib's startSaying:"Hello world, welcome to AppleScriptObjC" sender:me
--
set t2 to run script (do shell script "python -c 'import time; print time.time()'")
set time_diff to t2 - t1 - time_calib

on stringSpoken:theFlag
	if theFlag = 1 then
		beep 1
		log "The string was spoken"
	else
		--beep 2
		log "Trouble at mill"
	end if
end stringSpoken:

REMEMBER: you need to save Shanes other script posted above as instructed.

Thanks a lot,
kel