• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: If Statements
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: If Statements


  • Subject: Re: If Statements
  • From: Peter Baxter <email@hidden>
  • Date: Sun, 14 Sep 2008 08:02:29 +1000

Getting back to the original idea of recognising staff and students by the size of a number on a mixed password, The script below will differentiate between staff "0 to 99" and students 100 to infinity. That should do it.
If you remove the text from the numbers and then operate on the numbers in the password, the issue of string or number is immaterial. Try this script:


set the comparisonString to "0123456789"
set the sourceString to the text returned of (display dialog " Enter your password" default answer "" with hidden answer)
set the newText to ""
set the thisChar to ""
repeat with x from 1 to the count characters in sourceString
set myInteger to character x of sourceString
if myInteger is in comparisonString then
set newText to newText & myInteger
end if
end repeat
if (newText as number) is greater than 100 then
display dialog "Student"
else if (newText as number) is less than or equal to 100 then
display dialog "Staff"
end if



On 12/09/2008, at 3:22 PM, Tim Mansour wrote:


On 12/09/2008, at 3:13 pm, Ed Stockly wrote:

If userName were always a string, then

If (username > 1 and username <10)

would never work.


Or rather would work, but would return false.

As I interpret the OP, we can have

userName = "J Bloggs"

or

userName = "12345"

both of which are strings, but only the latter will coerce without error to a number.

--
Tim Mansour <email@hidden>



_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (applescript- email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users


This email sent to email@hidden

_______________________________________________ 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>)
 >Re: If Statements (From: Ed Stockly <email@hidden>)
 >Re: If Statements (From: Tim Mansour <email@hidden>)
 >Re: If Statements (From: Ed Stockly <email@hidden>)
 >Re: If Statements (From: Tim Mansour <email@hidden>)

  • Prev by Date: List of ITunes Applescript Commands
  • Next by Date: Re: List of ITunes Applescript Commands
  • Previous by thread: Re: If Statements
  • Next by thread: Re: If Statements
  • Index(es):
    • Date
    • Thread