Unique Macintosh Identification (Follow-Up)
Ken Ray
kray at sonsothunder.com
Fri Feb 22 07:09:01 EST 2002
(Cross-posted to MC list)
Hey, everyone: Here is what I ended up doing that not only retrieves the MAC Address, but also solves a reported problem of being unable to quit Apple System Profiler:
In order to get the MAC Address from Apple System Profiler, you first need to know that ASP refers to this as the "AppleTalk Address", and that it returns the address in AppleScript's list format (ex: {"00.0a.27.d6.9d.06"}). Secondly, you need to know where ASP *is*, otherwise you'll get the dreaded "Please locate Apple System Profiler:" dialog box. I discovered that if you can let MC locate it (through whatever means you need - directories(), files(), etc.), you need to make sure that the default directory is set to the location of ASP, otherwise you'll get the "Please locate:" box.
On my Mac (and I believe most modern OS8-9 Macs), ASP is located in the Apple Menu Items folder. So here's the script (assuming MC has found it in the Apple Menu Items folder):
function GetMACAddress
local tResult
set the directory to specialFolderPath("apple")
put "tell application" && quote & "Apple System Profiler" & quote & cr & \
"get appletalk address" & cr & "end tell" into getMACScript
put "tell application" && quote & "Apple System Profiler" & quote & cr & \
"close window" && quote & "Apple System Profiler" & quote & cr & "end tell" into quitASPScript
set the directory to specialFolderPath("apple")
do getMACScript as AppleScript
put the result into retVal
do quitASPScript as AppleScript
replace "{" with "" in retVal
replace "}" with "" in retVal
replace quote with "" in retVal
return retVal
end GetMACAddress
Note that although you can't send "quit" to ASP, you CAN say "close window 'Apple System Profiler'" and it does the same thing!
Enjoy!
Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.runrev.com/pipermail/use-livecode/attachments/20020222/88a9374c/attachment.htm>
More information about the use-livecode
mailing list