Re: If Statements
Re: If Statements
- Subject: Re: If Statements
- From: Matthew Smith <email@hidden>
- Date: Thu, 11 Sep 2008 22:26:13 +1000
- Thread-topic: If Statements
Title: Re: If Statements
on 11/09/2008 22:14 , William J Sisti at email@hidden wrote:
I have a If statement that checks users user name. Teachers use first initial and last name and students go by a number. So right now my Else if looks like this:
If (username > 1 and username <10)
do this
Else if (username > 11 and username < 20)
do this other thing
Else
do this third thing
End it
The problem is that the script doesn’t like trying to figure out if wsisti is between 1 and 10 or 11 and 20. “Can’t make kbasovsky into type number, date or text”.
My alternative is to add a another question to ask if they are a student or teacher and handle it that way, but I would rather not.
Your script is trying to convert username to a number so it can compare it with a number. It is a string. You can catch the error to determine if it is a number in a string or other type of text.
set username to "abc"
try
username + 10
set isTeacher to false
on error
set isTeacher to true
end try
if isTeacher then
...
else
...
end if
This will try to convert username to a number so it can add 10. The “on error” will be triggered if it can’t convert it.
--
Matthew Smith
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden
References: | |
| >If Statements (From: William J Sisti <email@hidden>) |