Friday, November 17, 2017

#1 2005-10-12 07:32:16 am

julifos
Administrator
From:: Malasaña, Madrid
Registered: 2002-11-20
Posts: 2014

Has the "computer" verb been removed in Mac OS X?

Well, not removed, but it has been renamed and moved. The Official AppleScript site has this to say about the change:

In Mac OS 9, scripters were able to access information about the computer via the "computer" verb in the Finder dictionary. This command was useful for determining the model of the computer, the current version of installed software, and many other necessary attributes.

In Mac OS X, this command has been removed from the Finder's dictionary and placed in the Standard Additions as the verb "system attribute". The command still functions in the same manner as before but can be used globally instead of only within a Finder tell block.

NOTE: If you are writing a script which will run within both Mac OS 9 and Mac OS X environments, place the command within a Finder tell block and it will work in both situations.

Here's an example script for determining the current version of QuickTime installed in Mac OS X.

Applescript:

-- CHECK THE VERSION OF QUICKTIME INSTALLED
-- this routine uses the gestaltVersion_info() sub-routine

copy my gestaltVersion_info("qtim", 8) to {QT_version, QT_string}

if the QT_version is less than "0500" then
   display dialog "This script requires QuickTime 5.0 or higher." & Ã?¬
       return & return & "The currently installed version is:" & Ã?¬
       QT_string buttons {"Cancel"} default button 1
end if

-- THIS ROUTINE USES THE SYSTEM ATTRIBUTE COMMAND TO GET VERSION INFO
on gestaltVersion_info(gestalt_code, string_length)
   try
       copy my number_to_hex((system attribute gestalt_code), Ã?¬
           string_length) to {a, b, c, d}
       set the numeric_version to {a, b, c, d} as string
       if a is "0" then set a to ""
       set the version_string to (a & b & "." & c & "." & d) as string
       return {numeric_version, version_string}
   on error
       return {"", "unknown"}
   end try
end gestaltVersion_info

on number_to_hex(hex_data, string_length)
   set hex_string to {}
   repeat with i from string_length to 1 by -1
       set hex_string to ((hex_data mod 16) as string) & hex_string
       set hex_data to hex_data div 16
   end repeat
   return (hex_string as string)
end number_to_hex

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)