I have this list:
property persons : {¬
{fnamn:"Mary", lnamn:"E Neumann"}, ¬
{fnamn:"Mark", lnamn:"Lance"}, ¬
{fnamn:"Connie", lnamn:"Mey"}, ¬
{fnamn:"Mary", lnamn:"E Neumann"}, ¬
{fnamn:"Mark", lnamn:"Lance"}, ¬
{fnamn:"Connie", lnamn:"Mey"}, ¬
{fnamn:"Mary", lnamn:"E Neumann"}, ¬
{fnamn:"Mark", lnamn:"Lance"}, ¬
{fnamn:"Connie", lnamn:"Mey"}, ¬
{fnamn:"Sara", lnamn:"Wern"}}
I want a random item from this list:
on getPerson(persons)
if (count of persons) > 0 then
set i to (random number from 1 to (count persons))
set person to item i of persons
When the random number is 1 I get this error??
tell current application
random number from 1 to 9
--> 1
(*Error: Can’t get items 1 thru 0 of {{fnamn:"Mary", lnamn:"E Neumann"}, {fnamn:"Mark", lnamn:"Lance"}, {fnamn:"Connie", lnamn:"Mey"}, {fnamn:"Mary", lnamn:"E Neumann"}, {fnamn:"Mark", lnamn:"Lance"}, {fnamn:"Connie", lnamn:"Mey"}, {fnamn:"Mark", lnamn:"Lance"}, {fnamn:"Connie", lnamn:"Mey"}, {fnamn:"Sara", lnamn:"Wern"}}. (-1728)*)
What does Can’t get items 1 thru 0 of mean?? Why “0”? Where does it come from?
I have tried this:
set i to (random number from 1 to 1)
set person to item i of persons
with the same list and it works every time.