Re: How to avoid the "Please Locate" prompt?
Re: How to avoid the "Please Locate" prompt?
- Subject: Re: How to avoid the "Please Locate" prompt?
- From: Kai Edwards <email@hidden>
- Date: Sun, 20 Oct 2002 16:23:28 +0000
on Sat, 19 Oct 2002 01:05:17 EDT, email@hidden wrote:
>
I've got 2 remaining "gotchas" that I'd like to hash out of this script, if
>
possible:
>
>
1) Can anyone tell me how I can avoid the "Please locate Network Setup
>
Scripting" dialog box that Applescript puts up the first time I run this.
>
Think I'd get in trouble if I hard-coded the path somehow?
To be on the safe side, you could use the Finder's 'application file id' to
locate the "Network Setup Scripting" app - and store the result in a script
property. However, to avoid problems when compiling[1], you'd then need to
use either a 'using terms from'[2] or 'double-tell'[3] block. Alternatively,
you might instead consider using Network Setup Scripting's raw codes[4].
>
2) Can anyone tell me if they get an error when running this under OS 8 or
>
9? I'd like to make sure this works under as many versions of OS 8/9 as
>
possible. If running properly, it should return your router address.
For various reasons, I can't check your script right now (sorry). However,
you might like to note that early versions of OS 8 could present specific
problems. For example, I can't recall exactly which OS version came with NSS
(8.5 or 8.6?) - but I'm pretty sure 8.1 didn't.
HTH
Kai
==========================================
[1] The direct form of tell, such as:
------------------------------------------
tell application "Network Setup Scripting"
------------------------------------------
...is what prompts dialogs like <Where is "Network Setup Scripting">. To
avoid this, an indirect form can be used instead - something like:
------------------------------------------
tell application NSS
------------------------------------------
...where NSS is a previously set variable/property that points to the
application's path. However, the AppleScript compiler may then refuse to
compile - since, to do so, it needs to know the terminology specific to the
application.
There are a few ways to get around this scripting 'catch 22', all of which I
believe have been discussed here from time to time. However, for the benefit
of those who haven't yet come across them, here are some examples:
==========================================
[2] 'using terms from' method:
------------------------------------------
using terms from application "Network Setup Scripting"
tell application NSS
-- do NSS stuff
end tell
end using terms from
------------------------------------------
==========================================
[3] 'double-tell' method:
------------------------------------------
tell application NSS to tell application "Network Setup Scripting"
-- do NSS stuff
end tell
------------------------------------------
==========================================
[4] raw code method:
Here's a modified version of your original script, using raw codes, which
now also replaces the app's name ("Network Setup Scripting") with its file
path (stored in the property 'NSS'):
-- replace << with opt-\
-- replace >> = shift-opt-\
------------------------------------------
property NSS : <<class msng>>
try
NSS as alias
on error
try
tell application "Finder" to set NSS to application file id "ntex" as string
on error
-- do something else
end try
end try
tell application NSS
try
<<event otaaotay>>
set currentConfig to <<class otbf>>
set tcpipConfig to <<class otdo>> 1 of currentConfig
set myResult to <<class otdq>> 1 of (<<class otdo>> 1 of currentConfig)
<<event otaaotax>>
on error errMsg number errNum
try
<<event otaaotax>>
end try
error errMsg number errNum
end try
end tell
------------------------------------------
--
email@hidden
email@hidden
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.