Re: IF Syntax
Re: IF Syntax
- Subject: Re: IF Syntax
- From: Emmanuel <email@hidden>
- Date: Fri, 4 Apr 2003 20:38:11 +0200
At 1:05 PM -0500 04/04/03, Peter Nedeljkovich wrote:
What is the correct syntax for an IF statement?
I'm trying to determine if Folder1 exists on a drive called Shared. If
it doesn't. then create it. Otherwise check for the existence of Folder2
and create it if it doesn't.
Your question is two-fold.
1. The syntax for if:
--------------------
if [boolean expression] then
[instructions]
else
[instructions]
end if
--------------------
Variantes:
--------------------
if [be] then [i]
--------------------
--------------------
if [be] then
[i]
else if [be] then
[i]
else if [be] then
[i]
end if
--------------------
2. To know whether Folder1 exists, there are various ways, some use
"if" other don't. My suggestion does not use "if", it uses
AppleScript's powerful error handling instead:
--------------------
try
alias "Shared:Folder1:"
[if the folder exists, script continues here]
on error
[if the folder does not exist, you jumped here]
end try
--------------------
Emmanuel
PS
Making a folder is the Finder's job. Check its dictionary. That one
could be a starter for you:
--------------------
tell application "Finder" to make new folder at alias "Shared" with
properties {name:"Folder1"}
--------------------
_______________________________________________
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.
References: | |
| >IF Syntax (From: "Peter Nedeljkovich" <email@hidden>) |