Re: Li'l help with if, then, else
Re: Li'l help with if, then, else
- Subject: Re: Li'l help with if, then, else
- From: "T.J. Mahaffey" <email@hidden>
- Date: Fri, 02 Mar 2001 04:56:04 -0600
Many thanks to this list
On 3/2/01 2:02 AM, T.J. Mahaffey <email@hidden> wrote:
>
The setup works beautifully, but if the "Utilities" folder IS present, it
>
still tries to make on and errors out due to there being a folder of the
>
same name already.
That's because you have to specify where to find the utilities folder.
Try this:
tell application "Finder"
if folder "Utilities" of startup disk exists then
try
** This works, but I'm proud to say I discovered this right after I hit
"send" on my post to the list. However, many thanks to Michelle for her
answer. This just helped bolster my logic. [*head inflating*]
Now, in my effort to streamline my script, I wanted to create a subroutine
of those three copy commands so I could call them more efficiently. Can
someone tell my why my subroutine isn't working? The script executes
seemingly ok, but never performs the copy commands assigned to the
subroutine.
tell application "Finder"
if folder "Utilities" of startup disk exists then
try
copyParts
display dialog "MacLab Network Assistant Setup is complete."
buttons {"Cancel", "Cool!"} default button 2 with icon 1
on error
display dialog "The Utils folder was already there."
copyParts
display dialog "MacLab Network Assistant Setup is complete."
buttons {"Cancel", "Cool!"} default button 2 with icon 1
end try
else
make folder in startup disk with properties {name:"Utilities"}
try
copyParts
display dialog "MacLab Network Assistant Setup is complete."
buttons {"Cancel", "Cool!"} default button 2 with icon 1
on error
display dialog "There was an error. The installer script will
now quit."
end try
end if
end tell
on copyParts()
tell application "Finder"
duplicate file "Network Assistant Preferences" of folder "Remote
Control Setup" of disk "MacLab NetAssist Setup" to folder "Preferences" of
folder "System Folder" of startup disk
duplicate file "Network Assistant Startup" of folder "Remote Control
Setup" of disk "MacLab NetAssist Setup" to folder "Extensions" of folder
"System Folder" of startup disk
duplicate folder "Network Assistant Folder" of folder "Remote
Control Setup" of disk "MacLab NetAssist Setup" to folder "Utilities" of
startup disk
end tell
end copyParts