beautypg.com

Apple AppleScript Finder Guide User Manual

Page 25

background image

C H A P T E R 1

Introduction to Finder Scripting

Writing Scripts That Control the Finder

13

Unlike the script in Listing 1-2, the script in Listing 1-3 consists of a single Tell

statement, and the Display Dialog command is invoked from within the

Tell statement. The dialog box asks for the name of the new user and stores it

in the variable newUser. The three statements that follow open the Users &

Groups control panel and use the Make command to create a new user object

with the name stored in newUser.
The rest of the Tell statement consists of a series of Set commands that create a

new folder on the startup disk with the new user’s name and set the folder’s

owner and group and its sharing privileges. The owner and members of the

Department Group have all sharing privileges set to true. The guest privileges

See Folders, See Files, and Make Changes are set to false, false, and true

respectively, so guests can drop items into the folder but can’t open it. These

privileges are signaled to guests by a belt around the folder and a small black

arrow above it.
For the script in Listing 1-3 to work correctly, file sharing must be turned on

and the computer on which the script is running must have a group named

Department Group. You can modify that name or other settings in the script

to suit your own purposes. You can also modify the script in a variety of other

ways. For example, you can add an If statement that checks for the presence

of a particular group and if necessary creates the group before creating the

new user.