Re: Non-modal information window showing progress?
Re: Non-modal information window showing progress?
- Subject: Re: Non-modal information window showing progress?
- From: email@hidden
- Date: Tue, 24 Apr 2001 21:50:16 -0400
On Monday, April 23, 2001, at 04:34 PM, Harald E Brandt wrote:
>
I want to display a progress window that says which file is currently being
processed. How can I do that??
>
Not a word about such a thing is mentioned in AppleScript Language Guide or in
Scripting_Additions.pdf!?
>
>
It should be like a progress bar, but with some text or numbers that are
updated as the script proceeds.
There are a number of application and Scripting Addition options.
"Transcript", "AppleScript Output", and "Message Window" are the application
solutions. All are easy to script, and provide slightly different displays.
Transcript is a scrolling text window that looks like a log file, adding each
message to the bottom of the window, showing all the messages all the way to the
beginning of time. I find it very good for debugging. Unfortunately, it seems
to interact poorly with other things I was using in a project (ListSTAR,
primarily) that lead to "out of memory" problems. I can't blame Transcript, but
jettisoning it made the problem go away, and I couldn't jettison ListSTAR.
Message Window displays a floating window with a single message that changes
whenever you tell it to. Its nice for status displays and user interaction.
AppleScript Output is also a floating window, but scrolls the text like
Transcript. Its also good for debugging. Sometimes, though, its presence
confuses the OS or the user as to where the cursor is and its as if the keyboard
becomes dead. (I think the problem is that if you click in the AppleScript
Output window, that window starts getting the events, but the active application
remains the original one.)
Also, the Scripting Addition "Akua Sweets" has "display info" and "display
progress" commands. Its much harder to work with since you have to tell it to
create the window before using it and destroy the window when you are done. But
you get greater control, and its much more efficient because the AppleEvents
don't have to travel between applications. It also makes for a more
understandable user experience because the info windows are displayed in the
script application itself, and not in some other app. (Displaying in another
app is nice for debugging, but displaying in the script application itself is
better for user feedback.)
My experience with Akua Sweets was that until I figured out all the subtleties
of the "display info" command, I'd run a script, it would create a window, and
then error out without closing the window. An hour of debugging would leave the
Script Editor littered with windows, and I'd have to quit and reopen Script
Editor to neaten things up. But the end result is nicer that what you can get
with an application solution.
For fancy displays I have used the web browser, generating an HTML file and then
telling the browser to open it. Its slow but powerful. You could probably
speed things up by scripting the browser to render a string using (in the case
of Internet Explorer) a "do script" command to generate some Javascript that
will render the window with "document.write()" calls. For example,
set html to "<html><head><title>Test</title></head>"
set html to html & "<body><h1>This is a test</h1></body></html>"
set jscript to "document.open();document.write('" & html & "')"
tell application "Internet Explorer" to do script jscript
You can also use the <<event GURLGURL>> (open location) to open the URL
javascript:document.open();document.write('<html><head><title>Test</title></
head><body><h1>This is a test</h1></body></html>')
(all on one line), but I had trouble making it work initially. I tried
modifying the script above to read,
set html to "<html><head><title>Test</title></head>"
set html to html & "<body><h1>This is a test</h1></body></html>"
set jscript to "document.open();document.write('" & html & "')"
open location "javascript:" & jscript
but the 'open location' command gives me "An error of type -666 has occured."
(Under OS 9.1 and AS 1.6). I found I needed to have an entry in the Internet
control panel to define the helper application for a "javascript:" URL. Once I
set it to my favorite browser, everything worked fine.
--
Scott Norton Phone: +1-703-299-1656
DTI Associates, Inc. Fax: +1-703-706-0476
2920 South Glebe Road Internet: email@hidden
Arlington, VA 22206-2768 or email@hidden