• 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
Why do I get this error?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why do I get this error?


  • Subject: Why do I get this error?
  • From: Michelle Steiner <email@hidden>
  • Date: Thu, 20 Apr 2006 00:35:36 -0700

This code works:

set thePack to {"AS", "KS", "QS", "JS", "10S", "9S", "8S", "7S", "6S", "5S", "4S", "3S", "2S", ¬
"AH", "KH", "QH", "JH", "10H", "9H", "8H", "7H", "6H", "5H", "4H", "3H", "2H", ¬
"AD", "KD", "QD", "JD", "10D", "9D", "8D", "7D", "6D", "5D", "4D", "3D", "2D", ¬
"AC", "KC", "QC", "JC", "10C", "9C", "8C", "7C", "6C", "5C", "4C", "3C", "2C"}
set theDeal to {}
repeat until thePack is {}
set theLength to the count of thePack
set foo to random number from 1 to theLength
copy item foo of thePack to end of theDeal
if foo is 1 then
set thePack to the rest of thePack
else if foo is (count of thePack) then
set thePack to items 1 through -2 of thePack
else
set thePack to items 1 through (foo - 1) of thePack & (items (foo + 1) through end of thePack)
end if
end repeat



The following code generates an error. The only difference between the two scripts is the word "the" before "end".


set thePack to {"AS", "KS", "QS", "JS", "10S", "9S", "8S", "7S", "6S", "5S", "4S", "3S", "2S", ¬
"AH", "KH", "QH", "JH", "10H", "9H", "8H", "7H", "6H", "5H", "4H", "3H", "2H", ¬
"AD", "KD", "QD", "JD", "10D", "9D", "8D", "7D", "6D", "5D", "4D", "3D", "2D", ¬
"AC", "KC", "QC", "JC", "10C", "9C", "8C", "7C", "6C", "5C", "4C", "3C", "2C"}
set theDeal to {}
repeat until thePack is {}
set theLength to the count of thePack
set foo to random number from 1 to theLength
copy item foo of thePack to end of theDeal
if foo is 1 then
set thePack to the rest of thePack
else if foo is (count of thePack) then
set thePack to items 1 through -2 of thePack
else
set thePack to items 1 through (foo - 1) of thePack & (items (foo + 1) through the end of thePack)
end if
end repeat



The error is this:

tell current application
	random number from 1 to 52
		11
	get items from item 12 to "2C"
		"Can't make items from item 12 to \"2C\" into type reference."

"items (foo + 1) through the end of thePack" is highlighted

--
"Every gun that is made, every warship launched, every rocket fired, signifies in the final sense a theft from those who hunger and are not fed, those who are cold and are not clothed."
President Dwight D. Eisenhower, April 16, 1953


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Why do I get this error?
      • From: kai <email@hidden>
  • Prev by Date: Re: Swap keyboard from "belgium" layout to US
  • Next by Date: Re: Unicode find/change
  • Previous by thread: Re: Unicode find/change
  • Next by thread: Re: Why do I get this error?
  • Index(es):
    • Date
    • Thread