[FOR NEW USERS] (was Re: new folders?)
[FOR NEW USERS] (was Re: new folders?)
- Subject: [FOR NEW USERS] (was Re: new folders?)
- From: Matt <email@hidden>
- Date: Sun, 17 Feb 2002 17:10:04 -0500 (EST)
Dave,
Welcome to AppleScript!
A quick and basic way to learn is by using "AppleScript Help" via Script
Editor's "Help" menu, and then Apple's Help Viewer will launch
and can be searched.
There are also a handful of books available that people have used with
varying success, and often, even the oldest references are still valid for
the basics. Try searching your favorite book seller (online or otherwise)
for "AppleScript" in the title. I both love and hate OReilly's
"AppleScript in a Nutshell" (lots of examples, but many make assumptions
and are not as clear as they may seem at first). Otherwise, "The Tao of
AppleScript" and "AppleScript Handbook" are two other older, but good
references for learning.
Another good start would be taking a look at:
http://www.apple.com/applescript
(lots of resources)
In the interim, here's the basic way to make a new folder that I found by
searching for "create folder" in Help Viewer and then following two links,
and with an "open" portion removed (4 lines - "make" starts the long one
and "end tell" is the next line after this long one as well as the last):
tell application "Finder"
activate
make new folder at desktop with properties {name:"Art Folder", label index:1, comment:"Copyright Art Studio 1999"}
end tell
...and a snippet for a dialog that has:
1) A text message with formatting
- "return" represents carriage returns to make new lines
2) 2 buttons expressly titled "Restart" and "Ignore"
- The names listed are what sets the number and name of buttons
- Removing the buttons portion will give the default buttons
- You are limited to up to 3 buttons
3) The default button is set to be "Restart"
- The number "2" below means the second button in the list
- Setting a default outlines the button
- The default button is also what is chosen using the Return key
4) The rest is pretty self-explanatory, but do note that there is no
catch or check for "Ignore", which just means that clicking it is
unimportant in terms of what the script cares about. There are other
options not shown, like giving up after a certain time (if no user is
there to click a button) and being able to tell if the user chose or if
the dialog gave up, etc.
I found Help Viewer lacking for dialogs, but all of the books have good
sections for this. Here's the script snippet (8 lines, with "display"
starting the long one and "set" starting the next line after this long
one):
tell application "Finder"
activate
display dialog ("Unable to make a connection." & return & "Please click Restart to restart your Macintosh and try again, or, click Ignore to continue using this computer." & return & return) buttons {"Ignore", "Restart"} default button 2
set theButton to (button returned of the result)
if theButton is equal to "Restart" then
restart
end if
end tell
Best of luck and hope I've helped,
-Matt
On Sun, 17 Feb 2002, dave wrote:
>
Hi. I am new to this applescripting lark. I'm trying to learn it from the
>
apple tutorial.
>
I would very much like to know how to tell the finder to create new folders,
>
or how to display dialogue. I haven't had much luck trying to find out.
>
Could anybody help me out with a couple of lines of code?
>
>
Thanks,
>
Dave
>
_______________________________________________
>
applescript-users mailing list | email@hidden
>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
>
Do not post admin requests to the list. They will be ignored.
>
Matthew Kozak
Rutgers University-Camden
email@hidden
**************************************************************************
"They that can give up essential liberty to obtain a little temporary
safety deserve neither liberty nor safety." -Ben Franklin
**************************************************************************
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.