Why do I get this error?
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