I'm working on a quick program in Applescript to help me study for a test, and I can't seem to get the random number generation right. Here's the program:
repeat
set page to (random number from 3 to 198) as text
set dialog1Text to "Page: " & page & "
How many paragraphs are on this page?"
display dialog dialog1Text default answer ""
set userNumParagraphs to text returned of result
set numParagraphs to (userNumParagraphs) as integer
set paragraph to (random number from 1 to numParagraphs) as text
set dialog2Text to "Paragraph: " & paragraph
display dialog paragraph
end repeat
There's one part that's not working. It's the random number generator, this part:
set paragraph to (random number from 1 to numParagraphs) as text
Applescript gives me this error:
Can’t set paragraph to (random number from 1 to numParagraphs) as text. Access not allowed.
I have done much research on the problem, but I can't find anything. I have looked for ways to generate a random number from a variable to a variable, but to no avail. I was wondering if any of you knew a way to do this. Any help that can be provided would be much appreciated. Thanks in advance.