Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

10.6. Exercises

  1. Modify the program that slides the Finder window from the top-left corner down to the right so that it moves instead from the bottom-left corner up to the top right of the screen. Assume you're working with a screen size of 1280 × 854 pixels.

  2. Type and run the following program, noting the output that appears in the Result pane:

    tell application "Finder" to set fileRef to get home
    fileRef

    Based on the result, write the following AppleScript statements. Be sure to test them and verify that you get the correct result.

    1. Rewrite the file reference as nested tell blocks.

    2. Write an AppleScript statement to get the Mac path equivalent for fileRef.

    3. Write an AppleScript statement to get the POSIX path equivalent for fileRef.

    4. Write an AppleScript statement to coerce fileRef into an alias.

  3. The following statement assigns the name of a text file in Linda's home folder to the variable todoFile.

    set toDoFile to "Macintosh HD:Users:linda:ToDo.txt"

    Given this assignment, write statements to do the following (as independent steps) in the Finder:

    1. Get the size of the file.

    2. Copy the file into your Documents folder.

    3. Rename the file to ToDoOld.txt.

    4. Delete the file.

    5. Create a new folder in your home directory called ToDoFolder and then move the file into the newly created folder.

    6. Count the number of files that start with ToDo in your home folder.

    7. Count the number of files that contain ToDo in their name in your home folder.

  4. Write a program to use the Finder to create an Internet location file on your desktop with the URL set to http://p2p.wrox.com. Make sure your file works by double-clicking it in the Finder and ensuring that the specified page is opened in your browser. Note: This exercise requires some digging and experimentation because this wasn't covered in detail in this chapter. Good luck!

  5. If you use the Address Book application, modify the example from this chapter to prompt for the person's first and last name. Then, if more than one match is found or more than one e-mail address exists, present the list of e-mails to the user and have him select a preferred e-mail address. Note: This is a difficult exercise. For each matching entry from the Address Book, you have to get every e-mail address and store it in a list.

  6. Modify the backup program from this chapter to prompt for the number of days and allow the user to select the folder to be scanned for backup.

  7. Turn the backup program developed in this chapter into a droplet so that it analyzes a single folder dropped onto its icon for files that are to be backed up. Make sure the program still runs correctly if it's launched from the Finder. That is, have it prompt for the folder as in the previous exercise. In either case, assume you are looking for files that have been modified within the last seven days.

  8. Modify the droplet developed in this chapter so that the title of the web page (the text that appears between the HTML <TITLE> and </TITLE> codes) is the base name of the images folder. Use that name as the heading for the web page (the text that appears between the HTML <H1> and </H2> codes).

  9. Modify the droplet developed in this chapter so that a list of folders and/or files can be dropped onto the droplet. Have the droplet create a web page from all the images in the folders (but not in any subfolders) and files.

  10. Write a droplet called File Me that works as follows: The droplet maintains a list of records (in the example that follows, it's called filingList). Each record contains a file extension and a corresponding folder alias. Each file dropped on the droplet is filed (that is, moved) into its corresponding folder. The last record should have a file extension of "*" and a folder that indicates where any files not matching the previous extensions are to be filed.

Look over the following code:


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint