• 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: Skeeve <email@hidden>
  • Date: Fri, 12 Sep 2008 08:43:38 +0200

Ed Stockly schrieb:
That's probably not going to work Ed becuase I suspect userName is always a string.

If userName were always a string, then

If (username > 1 and username <10)

would never work.

Of course Tim is right.

Test it for yourself

test_something("abc")
log "----------"
test_something("123")
log "----------"
test_something(123)

on test_something(something)
   log something
   log (class of something)
   try
       something as number
       log "Number"
       if something > 100 then
           log "> 100"
       else
           log "<= 100"
       end if
   on error
       log "String"
   end try
end test_something

As you will see from the output:
   (*abc*)
   (*string*)
   (*String*)
   (*----------*)
   (*123*)
   (*string*)
   (*Number*)
   (*> 100*)
   (*----------*)
   (*123*)
   (*integer*)
   (*Number*)
   (*> 100*)

"123" is of class string and so your "Stringthing" will always be done.

Nevertheless coercing it to a number gives you a number and you still can compare that string to numbers.
_______________________________________________
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
  • Follow-Ups:
    • Re: If Statements
      • From: Ed Stockly <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>)

  • Prev by Date: Re: If Statements
  • Next by Date: Re: Launching Default Mail Client Questions
  • Previous by thread: Re: If Statements
  • Next by thread: Re: If Statements
  • Index(es):
    • Date
    • Thread