FROM : Bill Cheeseman
DATE : Thu Aug 05 17:13:35 2004
on 2004-08-04 11:34 AM, Stiphane Sudre at <email_removed> wrote:
> NSAppleScriptErrorBriefMessage: "Connection is invalid."
>
> NSAppleScriptErrorMessage: "lambda got an error: Connection is invalid."
>
> NSAppleScriptErrorRange: nil
>
> If I don't run the QUIT script before, everything works fine.
>
> This is a bit annoying and I don't see any clever explanation why this
> would fail from a design point of view.
In your real scripts (as opposed to your emailed scripts), are you putting
the name of the target application in quotes, as in 'tell application
"lambda"'? (I take it that "lambda" is the actual name of the target
application.) I assume you are putting it in quotes, since you say the
scripts work except for the one problem scenario you identify.
The "connection is invalid" error message means the target application has
stopped running (i.e., it has quit, whether deliberately or "unexpectedly")
and a second command is sent to the same target application. The
"connection" it refers to is the connection to the AppleScript target.
I say this only as an observation of fact based on my own experience,
apparently confirmed by your experience. One would suppose that the second
script's 'tell' statement should relaunch lambda. The fact that it doesn't
would seem to be a bug.
You could try working around it by inserting a statement at the beginning of
the second script telling the Finder to 'open application file "lambda"'
followed by a 'delay n' command before the second 'tell application
"lambda"' in order to give lambda time to finish launching. You might also
try leaving out the Finder 'open' command and just go with the 'delay'
command, on the theory that you have to give AppleScript time to complete
the quit operation before sending the second tell. Set 'n' to a largish
value -- say 10 or 15 seconds -- then, if it works, try reducing the delay
to suit until it stops working.
To do some more diagnostics, you could insert 'beep' or 'display dialog'
commands at strategic points in both scripts, to see whether they are both
running and, if so, when. In Mac OS X 10.3 and newer, scripts normally queue
up and are executed in first in, first out order (it was the opposite before
10.3 which caused all sorts of difficulties). But they don't necessarily
always wait for one to signal completion before the next starts executing,
especially, I believe, when quitting or launching applications. For example,
put a 'beep' immediately before and after the 'quit' in the first script,
and listen for the second beep -- do you hear it before lambda has finished
quitting? Put a 'beep' immediately before the 'tell' statement in the second
script, and run the same test.
--
Bill Cheeseman - <email_removed>
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
The AppleScript Sourcebook - http://www.AppleScriptSourcebook.com
Vermont Recipes - http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
DATE : Thu Aug 05 17:13:35 2004
on 2004-08-04 11:34 AM, Stiphane Sudre at <email_removed> wrote:
> NSAppleScriptErrorBriefMessage: "Connection is invalid."
>
> NSAppleScriptErrorMessage: "lambda got an error: Connection is invalid."
>
> NSAppleScriptErrorRange: nil
>
> If I don't run the QUIT script before, everything works fine.
>
> This is a bit annoying and I don't see any clever explanation why this
> would fail from a design point of view.
In your real scripts (as opposed to your emailed scripts), are you putting
the name of the target application in quotes, as in 'tell application
"lambda"'? (I take it that "lambda" is the actual name of the target
application.) I assume you are putting it in quotes, since you say the
scripts work except for the one problem scenario you identify.
The "connection is invalid" error message means the target application has
stopped running (i.e., it has quit, whether deliberately or "unexpectedly")
and a second command is sent to the same target application. The
"connection" it refers to is the connection to the AppleScript target.
I say this only as an observation of fact based on my own experience,
apparently confirmed by your experience. One would suppose that the second
script's 'tell' statement should relaunch lambda. The fact that it doesn't
would seem to be a bug.
You could try working around it by inserting a statement at the beginning of
the second script telling the Finder to 'open application file "lambda"'
followed by a 'delay n' command before the second 'tell application
"lambda"' in order to give lambda time to finish launching. You might also
try leaving out the Finder 'open' command and just go with the 'delay'
command, on the theory that you have to give AppleScript time to complete
the quit operation before sending the second tell. Set 'n' to a largish
value -- say 10 or 15 seconds -- then, if it works, try reducing the delay
to suit until it stops working.
To do some more diagnostics, you could insert 'beep' or 'display dialog'
commands at strategic points in both scripts, to see whether they are both
running and, if so, when. In Mac OS X 10.3 and newer, scripts normally queue
up and are executed in first in, first out order (it was the opposite before
10.3 which caused all sorts of difficulties). But they don't necessarily
always wait for one to signal completion before the next starts executing,
especially, I believe, when quitting or launching applications. For example,
put a 'beep' immediately before and after the 'quit' in the first script,
and listen for the second beep -- do you hear it before lambda has finished
quitting? Put a 'beep' immediately before the 'tell' statement in the second
script, and run the same test.
--
Bill Cheeseman - <email_removed>
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
The AppleScript Sourcebook - http://www.AppleScriptSourcebook.com
Vermont Recipes - http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
| Related mails | Author | Date |
|---|---|---|
| Stéphane Sudre | Aug 4, 17:34 | |
| John Spicer | Aug 4, 17:56 | |
| Stéphane Sudre | Aug 4, 17:57 | |
| Stéphane Sudre | Aug 5, 14:42 | |
| Bill Cheeseman | Aug 5, 17:13 | |
| Bill Cheeseman | Aug 5, 17:39 |






Cocoa mail archive

