Updated 10/21/05
AppleScript
We use AppleScript every day in a variety of ways to produce the newspaper. As we build this site, we will give examples of how we use it along with links to the scripts.
For now, there are just four scripts in the AppleScript directory -- one for moving files from a Mac to a server volume and then cataloging the file in Cumulus; the other for counting files in directories and creating a log file of the results, one to send email via Microsoft Outlook when a server volume's disk space falls below 400 mb, and one to mount a server volume.
Description |
Script |
Changes Quark 6.5 text selection to first-letter caps |
|
Catalog graphics in Cumulus |
|
Count files in a directory and create a log file |
|
Mount a server volume after prompting user for logon and password |
|
Convert QPSCopyDesk Xtags to HTML tags |
|
Get name of current QuarkXpress box |
|
Get path to images in QuarkXpress file and save this to a file |
|
Send email via Microsoft Outlook (requires iDo Script Scheduler) |
|
Date Formatter (returns date in numeric format) by Greg Weber |
|
Replace Zapf Dingbat bullets in Quark Xpress documents |
|
Replace regular quotes with smart quotes in text files |
|
Some Code
Here's a short script to mount an AppleTalk server volume without using the chooser. It prompts the user for a user name and password, then mounts the server volume. This version was written to mount a Windows NT Mac volume and authenticate the user via Active Directory. It adds the us\ prefix to the user name to force this authentication without the user knowing it. Comments are in blue.
-- check the computer's default user name and use it as the default
get owner name
set defaultname to result as string
-- display a dialog asking for the user's name
set temp to display dialog "What is your logon?" default answer defaultname with icon 2
set userName to text returned of temp as string
-- add the Active Directory string (us\) to the start of the user name
set userNameAD to "us\\" & userName as string
-- display a dialog asking for the user's password
set passtemp to display dialog "What is your password?" default answer "" with icon 2
set Userpassword to result
--assemble all the details and mount the volume with this command
mount volume "Newsroom" on server "TCLNEWS1" in AppleTalk zone "Editorial" as user name userNameAD with password Userpassword
Here's a script sample for Adobe Illustrator 10. It's a function that you ca
n call from RealBasic (or from within Applescript itself) to change the color of a polygon.
--pass the name of the box to the function
on run {theBox}
--Activate Illustrator
tell application "Adobe Illustrator 10"
--tell illustrator to set the color of the box to 90% yellow, 20% cyan
set the fill color of path item theBox of document 1 to {yellow:90.0, cyan:20.0}
--finish up
end tell
end run
|