DekGenius.com
Team LiB   Previous Section   Next Section
using terms from end [using terms from]

Syntax

Tell app "Finder" of machine "eppc://192.168.0.2"
   Using terms from app "Finder"
      Get largest free block
   End using terms from
End tell

Description

This block structure allows the scripter to compile a script using local applications and to have the option to run the script on remote machines using a TCP/IP or AppleTalk network. Chapter 25, describes how to use the Mac's powerful new program linking technology to run distributed AppleScripts over TCP/IP networks. using terms from is new to AppleScript 1.4. Similar to the tell block, it takes an application object as a parameter, as in:

using terms from app "Finder"

You use this construct to help avoid the display of the Script Editor dialog box that asks for the location of the target application in a tell block. This dialog box usually displays when the script is first compiled and then whenever the script is executed on a different machine. If you have not encountered this dialog box yet during AppleScript hacking, then you are either lucky or just haven't done very much AppleScripting.

Examples

using terms from is best illustrated with this example, which dynamically targets whatever machine you want, but compiles using terms from the local machine:

set theMachine to "eppc://" & the text returned of¬
(display dialog "Enter your IP address:" default answer "")
try
   tell application "Finder" of machine theMachine
      using terms from application "Finder"
         set freeMem to (round (largest free block / 1024 / 1024)) as¬ 
         string
         display dialog freeMem
      end using terms from
   end tell
on error errMsg
   display dialog errMsg
end try

This script targets the Finder on a particular Apple machine (depending on what the script user enters as the machine name or IP address). The script compiles, however, using its local Finder app. If the user enters an invalid or nonexistent IP address, then an error is raised and reported at the end of the try block. When targeting applications over a TCP/IP network, you have to precede the IP address with the protocol "eppc://", which stands for "event program to program communications":

tell application "Finder" of machine "eppc://192.168.0.2"
    Team LiB   Previous Section   Next Section