• 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: display message while script is running
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: display message while script is running


  • Subject: Re: display message while script is running
  • From: kai <email@hidden>
  • Date: Wed, 8 Dec 2004 19:22:21 +0000


On Monday, December 6, 2004, at 04:45 am, I wrote:

On Thu, 2 Dec 2004 13:27:21 +0100, Jan-Bultereys wrote:

I have a script where the runtime is pretty long....

Is there a way to display a message on the screen while the script is running and
disappear when it's done?

If you *really* wanted to do this with vanilla dialogs, Jan, then you may be able to achieve it by splitting the job between 2 scripts. (The example below opens and closes several dialogs as the main script progresses.)


The purpose of the following short script would be to merely display the dialog(s):

-----------------

to displayDialog(msg)
activate
display dialog msg buttons {"Processing..."} default button 1 with icon 1
end displayDialog


-----------------

Save this as a stay-open application called, say, "Progress Indicator".

The main script might then work something like this:


[snip: main script]

My suggested (snipped) code evidently raised an issue. To help clarify the details, here are some extracts from a subsequent off-list exchange, along with a modified version of the main script:

On Monday, December 6, 2004, at 02:40  pm, Jan-Bultereys wrote:

thanks Kai,

Pretty good approach, got it running 1 time and then got
error:
System Events got an error: NSReceiverEvaluationScriptError: 4

any idea where it's comming from?

I can only guess, Jan. These NSxxxx errors don't seem that helpful - and the script works fine OMM as it stands (OS 10.2.8). It's obviously not that easy to test for an issue that doesn't arise here. (Are you running Panther?)


My original script included an explicit statement to launch the "Progress Indicator" applet. Since the statement didn't appear to be necessary for the script to work here, I removed it. However, it's possible that the initial absence of "Progress Indicator" might be causing a problem for you - in the first couple of lines of the 'closeDialog' handler (...tell process "Progress Indicator"... set frontmost to true). On reflection, it's perhaps curious that the omission of a launch statement doesn't result in an error here.

You might therefore try reinstating my original launch statement as indicated below:

-----------------

to closeDialog()
tell application "System Events" to tell process "Progress Indicator"
set frontmost to true
if (count windows) > 0 then keystroke return
end tell
end closeDialog


to openDialog(msg)
	closeDialog()
	ignoring application responses
		tell application "Progress Indicator" to displayDialog(msg)
	end ignoring
end openDialog

launch application "Progress Indicator"

repeat with n from 1 to 3
	openDialog("Please wait while item " & n & " is processed...")
	delay 3 -- simulate processing
end repeat

closeDialog()

ignoring application responses
	quit application "Progress Indicator"
end ignoring

-----------------

Perhaps you could let me know how you get on. If the above statement fixes the problem, I may post an amendment on-list - just in case anyone else attempts to use the code.

On Wednesday, December 8, 2004, at 07:15 pm, I wrote:

On Tuesday, December 7, 2004, at 08:43  am, Jan-Bultereys wrote:

hi kai,

yes this is working, ran a couple of times and it doesn't give me any errors....

FYI, I am running X.3.5

thanks very much for your input and have a nice day... :)

Thanks, Jan. Good to know that the suggested modification works both OYM and OMM. :-)

--- kai

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: display message while script is running (From: kai <email@hidden>)

  • Prev by Date: Re: swf movie
  • Next by Date: Re: Filemaker
  • Previous by thread: Re: display message while script is running
  • Next by thread: Next Philadelphia Area AppleScript Users Group Meeting
  • Index(es):
    • Date
    • Thread