Differences between loop terminations

Is there any difference between these?..

to doThis()
repeat
if something is whatever then
doSomethingElse()
end if
end repeat
end doThis

to doThis()
repeat
if something is whatever then
exit repeat
end if
end repeat
doSomethingElse()
end doThis

They both seem to work. I 'm just curious if one is better to use than the other in AS.

Perhaps one of these is what you would prefer:


repeat until (something is whatever)
	doSomethingElse()
end

-- or

repeat while (something is whatever)
	doSomethingElse()
end

Assuming, of course, that doSomethingElse is changing the state of “something.”

Actually, there would be several “untils” for the script to check, so I made them all “ifs”
Since my last post I had a couple “Stack Overflows” Which seem to happen in the same handler no matter which of my versions I use. I didn’t want to paste it all in here cuz it’s so long (maybe THATS the problem?), but here goes. It’s part of a Typing-Practice thingy in case you wanna know. Please let me know what you think of this mess…


to getlevel()
	
	repeat
		if wpm < 6 then
			set the chosenWord to some item of {"asdf", "afds", "sfad", "dsfa", "jkls", "ljka", "jaks", "lfks", "sjal", "fjsl", "lkds", "kjfd", "alsk", "ajdl", "jlfs"} as string
		end if
		
		if wpm > 5 then
			if wpm < 10 then
				set the chosenWord to some item of {"ahsdf", "afhds", "sfagd", "hdsfa", "jklgs", "lhjka", "jhaks", "lfksg", "sjhal", "gfjsl", "lkdsh", "kjfgd", "ahlsk", "ajdgl", "jhlfs", "ghfjd", "flash", "glads", "ksgha", "lhgsj"} as string
			end if
		end if
		
		if wpm > 9 then
			if wpm < 15 then
				set the chosenWord to some item of {"stew", "huge", "polite", "ploy", "swat", "rough", "read", "quiet", "pride", "dead", "deal", "kill", "hurt", "shirt", "justify", "height", "flush", "they", "used", "pout", "proud", "trout", "great", "gift", "queer", "iraq", "wade", "quote", "thought", "kite", "pike", "lake", "fake", "freak", "treat", "trees", "rush", "trash", "dry", "droop", "pair", "fright", "fryer", "flight", "spite", "trout", "read", "seed", "dear", "poke", "speed", "seed", "ripe", "quilt", "dark", "dusk", "yard", "party", "dirty", "flirt", "flower", "flour", "squirt", "square", "jail", "jerk", "jimmy", "jewish"} as string
			end if
		end if
		
		if wpm > 14 then
			if wpm < 25 then
				set the chosenWord to some item of {"hello", "Gary", "button", "laxative", "next", "xerox", "extreme", "excited", "house", "tonight", "cigarette", "kitchen", "Milwaukee", "Wisconsin", "Franklin", "penny", "nickle", "dime", "quarter", "dollar", "king", "queen", "jack", "ten", "nine", "eight", "seven", "six", "five", "four", "three", "two", "one", "zero", "after", "army", "apple", "ace", "blue", "brown", "red", "yellow", "rhyme", "green", "black", "white", "iraq", "iran", "bingo", "beatles", "ghost", "sign", "president", "exit", "enter", "door", "window", "zipper", "jazz", "buzzard", "blizzard", "century", "circus", "days", "enough", "elephant", "echo", "flight", "french", "hat", "hour", "ink", "itch", "jinx", "jerk", "lamp", "listen", "mouth", "mice", "market", "never", "knife", "north", "opera", "ounce", "park", "punt", "resist", "run", "rope", "sit", "shelf", "start", "store", "square", "time", "that", "them", "try", "under", "above", "uncle", "usher", "vice", "vote", "work", "when", "winter", "wonderful", "year", "typist", "television", "lazy", "guitar", "water", "sugar", "orange", "rake", "injury", "tissue", "empty", "automobile", "crazy", "happiness", "munch", "crunch", "examine", "burn", "verse", "over", "squint", "squeeze"} as string
			end if
		end if
		if wpm > 24 then
			set the chosenWord to some item of {"Hello, how are you today?", "Gary is a very cool dude.", "Button your flannel shirt.", "The fireplace burned brightly.", "Tonight is all we have.", "Smoke gets in your eyes.", "Let's paint the kitchen purple!", "Milwaukee is the beer capitol.", "Wisconsin is the dairy state.", "Franklin is very near to Milwaukee.", "A penny earned isn't much.", "A nickle equals five cents.", "Two nickles equal one dime.", "I'll have a quarter pounder.", "Can I have a dollar?", "king Henry had headless wives!", "A queen bee is huge!", "Jack sprat ate no fat.", "Ten people ran that way.", "Nine comes right after eight.", "Eight tacos with hot sauce.", "Six feet deep sounds good.", "Five threes is a Yahtzee!", "The dog wants to go for a walk.", "Three little pigs arrested me.", "Two more for the road!", "One is the loneliest number.", "Here's your prize.", "The aspirin is in the medicine cabinet.", "Our army is much bigger.", "Don't eat the poison apple.", "The ace is the highest.", "The grey sky turned blue.", "I want to drive the van next.", "Do my eyes look red?", "Your yellow shirt is dirty.", "Axe doesn't rhyme with bird.", "Is the lawn green yet?", "Black widow spiders scare me.", "Reggie White sacked the quarterback!", "Iraq is nice to visit.", "Iran harbors terrorists no more.", "Bob Dylan wrote excellent lyrics.", "Casper is a friendly ghost.", "The sign is located above the door.", "Please vote for president Bush.", "The exit is that way.", "Don't enter while I'm showering.", "We need new carpeting in here.", "Wash the window with ammonia.", "My zipper is stuck again!", "Jazz music can relax me.", "The buzzard circled our camp.", "This blizzard better stop soon!", "That happened nearly a century ago.", "Circus clowns drive little cars.", "Forty days and forty nights.", "That's enough spaghetti for me.", "Elephants can remember very well.", "Do you hear an echo?", "Flight was a great invention.", "French people hate french fries.", "This knife isn't sharp anymore.", "A compass always points north.", "Good Opera hurts my ears.", "How many ounces was that?", "Don't park in my spot!", "Please don't punt the ball.", "How can you resist me?", "Walk, don't run in here.", "Is that rope tied securely?", "Just sit down and watch.", "The shelf can't hold that.", "Let's start all over again.", "Squirrels store all their nuts.", "Squares can't fit into circles!", "Time is on my side.", "It takes a lot to laugh, but it takes a train to cry.", "Some are smears, and some are spots.", "Al Gore invented the internet.", "Still crazy after all these years.", "Megan wishes she could be cool like Gary.", "Go fly a kite.", "Do chickens have lips?"} as string
		end if
		set wordCheck to items in chosenWord
		
		if practiceList is "" then
			exit repeat
		end if
		
		if practiceOn = "off" then
			exit repeat
		end if
		
		if practiceLetter is in wordCheck then
			set practiceletterstring to "It's time to practice the letter " & practiceLetter & "."
			exit repeat
		end if
	end repeat
	giveWord()
end getlevel

I am sooooo sorry for this long post! :frowning:

A compound if-then-else statement will make things easier to follow and I don’t think that block needs to be in the repeat loop (there are also a few other minor tweaks):

Jon

Wow! That looks MUCH neater, and it work great. Thank you x 1000.
I still haven’t tested it enough to find out if my sloppy code was the culprit for the Stack Overflow. Could the cause have been somewhere else in the script even-though it always seems to happen in the same sub_routine()?? I guess I’ll find out after I run it a few times, but if you have the answer please let me know.
Thanks again,
-G

It’s very hard to say why you were getting the error without seeing all of your code. In case you were interested, building on the limited code you posted, here’s my attempt at a typing quiz:

property continue_flag : ""
property practice_letters : characters of "adfjkls"
property practice_letter : ""
property practice_letter_string : ""
property test_string : ""

set continue_flag to true
repeat with i from 1 to (count practice_letters)
	set practice_letter to item i of practice_letters
	set practice_letter_string to "It's time to practice the letter ?" & practice_letter & "?."
	set wpm to 1
	repeat while wpm < 40
		my set_test_string()
		my run_test()
		if continue_flag = false then return
	end repeat
end repeat

on run_test()
	set {the_error, the_icon} to {"", 1}
	repeat
		set start_time to (current date)
		activate
		set the_result to text returned of (display dialog practice_letter_string & return & return & the_error & "Type this:" & return & return & test_string default answer "" buttons {"OK"} default button 1 with icon the_icon)
		considering case, punctuation and white space
			if the_result = test_string then
				set total_time to (current date) - start_time
				set wpm to (round of ((60 / total_time) * (count of words of test_string)))
				exit repeat
			end if
		end considering
		set {the_error, the_icon} to {"Sorry, try again. ", 2}
	end repeat
	activate
	if button returned of (display dialog ("It took you " & total_time & " seconds (" & (wpm as string) & " wpm) to type:" & return & return & test_string) buttons {"Quit", "OK"} default button 2 with icon 1 giving up after 2) = "Quit" then set continue_flag to false
end run_test

on set_test_string()
	if wpm is less than or equal to 5 then
		set the_list to {"asdf", "afds", "sfad", "dsfa", "jkls", "ljka", "jaks", "lfks", "sjal", "fjsl", "lkds", "kjfd", "alsk", "ajdl", "jlfs"}
	else if wpm is less than or equal to 10 then
		set the_list to {"ahsdf", "afhds", "sfagd", "hdsfa", "jklgs", "lhjka", "jhaks", "lfksg", "sjhal", "gfjsl", "lkdsh", "kjfgd", "ahlsk", "ajdgl", "jhlfs", "ghfjd", "flash", "glads", "ksgha", "lhgsj"}
	else if wpm is less than or equal to 15 then
		set the_list to {"stew", "huge", "polite", "ploy", "swat", "rough", "read", "quiet", "pride", "dead", "deal", "kill", "hurt", "shirt", "justify", "height", "flush", "they", "used", "pout", "proud", "trout", "great", "gift", "queer", "iraq", "wade", "quote", "thought", "kite", "pike", "lake", "fake", "freak", "treat", "trees", "rush", "trash", "dry", "droop", "pair", "fright", "fryer", "flight", "spite", "trout", "read", "seed", "dear", "poke", "speed", "seed", "ripe", "quilt", "dark", "dusk", "yard", "party", "dirty", "flirt", "flower", "flour", "squirt", "square", "jail", "jerk", "jimmy", "jewish"}
	else if wpm is less than or equal to 25 then
		set the_list to {"hello", "Gary", "button", "laxative", "next", "xerox", "extreme", "excited", "house", "tonight", "cigarette", "kitchen", "Milwaukee", "Wisconsin", "Franklin", "penny", "nickle", "dime", "quarter", "dollar", "king", "queen", "jack", "ten", "nine", "eight", "seven", "six", "five", "four", "three", "two", "one", "zero", "after", "army", "apple", "ace", "blue", "brown", "red", "yellow", "rhyme", "green", "black", "white", "iraq", "iran", "bingo", "beatles", "ghost", "sign", "president", "exit", "enter", "door", "window", "zipper", "jazz", "buzzard", "blizzard", "century", "circus", "days", "enough", "elephant", "echo", "flight", "french", "hat", "hour", "ink", "itch", "jinx", "jerk", "lamp", "listen", "mouth", "mice", "market", "never", "knife", "north", "opera", "ounce", "park", "punt", "resist", "run", "rope", "sit", "shelf", "start", "store", "square", "time", "that", "them", "try", "under", "above", "uncle", "usher", "vice", "vote", "work", "when", "winter", "wonderful", "year", "typist", "television", "lazy", "guitar", "water", "sugar", "orange", "rake", "injury", "tissue", "empty", "automobile", "crazy", "happiness", "munch", "crunch", "examine", "burn", "verse", "over", "squint", "squeeze"}
	else
		set the_list to {"Hello, how are you today?", "Gary is a very cool dude.", "Button your flannel shirt.", "The fireplace burned brightly.", "Tonight is all we have.", "Smoke gets in your eyes.", "Let's paint the kitchen purple!", "Milwaukee is the beer capitol.", "Wisconsin is the dairy state.", "Franklin is very near to Milwaukee.", "A penny earned isn't much.", "A nickle equals five cents.", "Two nickles equal one dime.", "I'll have a quarter pounder.", "Can I have a dollar?", "king Henry had headless wives!", "A queen bee is huge!", "Jack sprat ate no fat.", "Ten people ran that way.", "Nine comes right after eight.", "Eight tacos with hot sauce.", "Six feet deep sounds good.", "Five threes is a Yahtzee!", "The dog wants to go for a walk.", "Three little pigs arrested me.", "Two more for the road!", "One is the loneliest number.", "Here's your prize.", "The aspirin is in the medicine cabinet.", "Our army is much bigger.", "Don't eat the poison apple.", "The ace is the highest.", "The grey sky turned blue.", "I want to drive the van next.", "Do my eyes look red?", "Your yellow shirt is dirty.", "Axe doesn't rhyme with bird.", "Is the lawn green yet?", "Black widow spiders scare me.", "Reggie White sacked the quarterback!", "Iraq is nice to visit.", "Iran harbors terrorists no more.", "Bob Dylan wrote excellent lyrics.", "Casper is a friendly ghost.", "The sign is located above the door.", "Please vote for president Bush.", "The exit is that way.", "Don't enter while I'm showering.", "We need new carpeting in here.", "Wash the window with ammonia.", "My zipper is stuck again!", "Jazz music can relax me.", "The buzzard circled our camp.", "This blizzard better stop soon!", "That happened nearly a century ago.", "Circus clowns drive little cars.", "Forty days and forty nights.", "That's enough spaghetti for me.", "Elephants can remember very well.", "Do you hear an echo?", "Flight was a great invention.", "French people hate french fries.", "This knife isn't sharp anymore.", "A compass always points north.", "Good Opera hurts my ears.", "How many ounces was that?", "Don't park in my spot!", "Please don't punt the ball.", "How can you resist me?", "Walk, don't run in here.", "Is that rope tied securely?", "Just sit down and watch.", "The shelf can't hold that.", "Let's start all over again.", "Squirrels store all their nuts.", "Squares can't fit into circles!", "Time is on my side.", "It takes a lot to laugh, but it takes a train to cry.", "Some are smears, and some are spots.", "Al Gore invented the internet.", "Still crazy after all these years.", "Megan wishes she could be cool like Gary.", "Go fly a kite.", "Do chickens have lips?"}
	end if
	repeat
		set test_string to item (random number from 1 to (count the_list)) of the_list
		if practice_letter is in test_string then exit repeat
	end repeat
end set_test_string

Jon


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

It took you a few minutes to do what I’ve been trying for a week! Your not too far off from my script except my code is MUCH sloppier, and I was attempting to keep a running total of “Words Per Minute” and I’m basing the time on 5 letters per word so “try” is worth less time than “president”. I got the error again with your new subroutine, so the problem must be somewhere else. Maybe you can figure it out, if you want to wade through all this? I can’t be too far off (I hope). I can already see a few things I can fix by looking at your script.


property mistakeliststring : ""
property practiceletterstring : ""
property practiceLetter : ""
property practiceList : ""
property practiceOn : ""
property wordCheck : " "
property mistakeList : " "
property ALetter : " "
property startTime : ""
property timeDifference : ""
property endTime : ""
property theTypedWord : ""
property wpm : 0
property chosenWord : ""
property number_correct : 0
property wpmstring : ""
property avNumWords : ""

--*************************
--*************************

reset()

--*************************
--*************************

to reset()
	set practiceOn to "on"
	set startTime to 0
	set endTime to 0
	set timeDifference to 0
	set number_correct to 0
	set wpm to 0
	set wpmstring to ""
	set practiceList to ""
	set practiceLetter to ""
	set mistakeList to ""
	set mistakeliststring to ""
	set practiceletterstring to ""
	set wordCheck to ""
	set ALetter to ""
	set startTime to ""
	set theTypedWord to ""
	set chosenWord to ""
	set wpmstring to ""
	set avNumWords to ""
	-----------------------------------------------	
	display dialog "                    GassyTypingPractice 1.0
		
	Type the letters above the text area,
	as in the example below.
		
	example" default answer "example" buttons {"Cancel", "START"} default button "START"
	
	PreSet()
	
end reset

--*************************
--*************************

to PreSet()
	
	--After five minutes of practice, stop and show user the score...
	if timeDifference > 5 then
		showscoreEnd()
	end if
	
	--Get letters user is having troble with, if there are any...
	try
		set practiceLetter to some item in practiceList
		
	end try
	
	set practiceletterstring to ""
	
	getlevel()
	
end PreSet

--*************************
--*************************

to giveWord()
	
	--Toggle Practice-mode so every other word or sentence contains letters user has trouble with...
	if practiceOn is "off" then
		set practiceOn to "on"
	else
		set practiceOn to "off"
	end if
	
	--Count the letters in the chosen word (includes spaces, periods, commas, etc. for sentences)...
	set numLetters to count of chosenWord
	
	set avNumWords to numLetters / 5
	
	set startTime to current date
	
	--Let user see the word to be typed, along with their Words Per Minute, and problem letters...
	display dialog "                    GassyTypingPractice 1.0
		
		" & wpmstring & "
		" & practiceletterstring & "
		
		" & chosenWord default answer "" buttons {"Cancel", "PAUSE", "NEXT"} default button "NEXT"
	copy the result as list to {theTypedWord, button_pressed}
	
	--User wants to see score before time is up, so that's what we'll do...
	if button_pressed is "PAUSE" then
		showscore()
	end if
	
	--User pressed "NEXT", and a word or sentence is misspelled...
	if theTypedWord ? chosenWord then
		--Make the user retype the word that was just mistyped...
		getbadletter()
	end if
	goodAnswer()
	
end giveWord

--*************************
--*************************

to goodAnswer()
	
	--The word or sentence was typed correctly, so get the time...
	set endTime to current date
	
	--get time in minutes between start of practice and the last word typed...
	set timeDifference to timeDifference + (endTime - startTime) / 60
	
	--Add the amount of words the user typed correctly...
	set number_correct to number_correct + avNumWords as string
	
	--Get words per minute & round up to whole number...
	try
		set wpm to (number_correct / timeDifference)
		set wpm2 to (number_correct / timeDifference) as string
	end try
	
	if (count of wpm2) > 3 then
		set wpmstring to items 1 thru 4 of wpm2 & " words per minute. " as string
		
	else if (count of wpm2) < 4 then
		set wpmstring to wpm2 & " words per minute. " as string
		
	end if
	
	PreSet()
	
end goodAnswer

--*************************
--*************************

to getbadletter()
	
	beep 1
	
	--Create a name for the screw-up.  "Oops" sounds good to me...
	set oops to theTypedWord as text
	
	--Break mistyped word into letters...
	set typedletters to items in oops
	
	--With each letter in the word the user should've gotten right...
	repeat with ALetter in chosenWord
		
		--Find the letter/s the user didn't type...
		if typedletters does not contain ALetter then
			
			--If the screwed-up letter isn't in the list of FORMER screwed-up letters...
			if ALetter is not in mistakeList then
				
				--If the screwed-up letter isn't a period, comma, etc... 
				if ALetter is not in {" ", ",", ".", "'", "?", "!", ""} then
					
					--Add the screwed-up letter to the list of problem letters displayed to user...
					set mistakeList to mistakeList & " " & ALetter
					--Add the screwed-up letter to the list of letters the user needs to practice...
					set practiceList to practiceList & ALetter
					
				end if
			end if
		end if
		
	end repeat
	
	badDialog()
	
end getbadletter

--*************************
--*************************

to badDialog()
	
	display dialog "                    GassyTypingPractice 1.0
		
		" & wpmstring & "
		OOPS!---> " & theTypedWord & "
		
		" & chosenWord default answer "" buttons {"Cancel", "PAUSE", "NEXT"} default button "NEXT"
	copy the result as list to {theTypedWord, button_pressed}
	
	--User wants to see score before time is up, so that's what we'll do...
	if button_pressed is "PAUSE" then
		showscore()
	end if
	
	--The user screwed-up the same word or sentence again!...
	if theTypedWord ? chosenWord then
		getbadletter()
	end if
	
	goodAnswer()
	
end badDialog

--*************************
--*************************

to showscore()
	if mistakeList ? "" then
		set mistakeliststring to "Some letters you need to practice:
		" & mistakeList
	else
		set mistakeliststring to ""
	end if
	
	set theTypedWord to ""
	set chosenWord to ""
	beep 3
	
	display dialog "                    GassyTypingPractice 1.0
		
		You typed " & wpmstring & "
		" & mistakeliststring buttons {"Cancel", "Start Over", "Continue"} default button 3
	
	if button returned of the result is "Continue" then
		
		PreSet()
	else
		reset()
	end if
	
end showscore

--*************************
--*************************

to showscoreEnd()
	
	set theTypedWord to ""
	set chosenWord to ""
	beep 3
	
	display dialog "                    GassyTypingPractice 1.0
		
		You typed " & wpmstring & "
		" & mistakeliststring buttons {"Cancel", "Let's do that again!"} default button 2
	
	reset()
	
end showscoreEnd

--*************************
--*************************

to getlevel()
	if wpm is less than or equal to 5 then
		set the_list to {"asdf", "afds", "sfad", "dsfa", "jkls", "ljka", "jaks", "lfks", "sjal", "fjsl", "lkds", "kjfd", "alsk", "ajdl", "jlfs"}
	else if wpm is less than or equal to 10 then
		set the_list to {"ahsdf", "afhds", "sfagd", "hdsfa", "jklgs", "lhjka", "jhaks", "lfksg", "sjhal", "gfjsl", "lkdsh", "kjfgd", "ahlsk", "ajdgl", "jhlfs", "ghfjd", "flash", "glads", "ksgha", "lhgsj"}
	else if wpm is less than or equal to 15 then
		set the_list to {"stew", "huge", "polite", "ploy", "swat", "rough", "read", "quiet", "pride", "dead", "deal", "kill", "hurt", "shirt", "justify", "height", "flush", "they", "used", "pout", "proud", "trout", "great", "gift", "queer", "iraq", "wade", "quote", "thought", "kite", "pike", "lake", "fake", "freak", "treat", "trees", "rush", "trash", "dry", "droop", "pair", "fright", "fryer", "flight", "spite", "trout", "read", "seed", "dear", "poke", "speed", "seed", "ripe", "quilt", "dark", "dusk", "yard", "party", "dirty", "flirt", "flower", "flour", "squirt", "square", "jail", "jerk", "jimmy", "jewish"}
	else if wpm is less than or equal to 25 then
		set the_list to {"hello", "Gary", "button", "laxative", "next", "xerox", "extreme", "excited", "house", "tonight", "cigarette", "kitchen", "Milwaukee", "Wisconsin", "Franklin", "penny", "nickle", "dime", "quarter", "dollar", "king", "queen", "jack", "ten", "nine", "eight", "seven", "six", "five", "four", "three", "two", "one", "zero", "after", "army", "apple", "ace", "blue", "brown", "red", "yellow", "rhyme", "green", "black", "white", "iraq", "iran", "bingo", "beatles", "ghost", "sign", "president", "exit", "enter", "door", "window", "zipper", "jazz", "buzzard", "blizzard", "century", "circus", "days", "enough", "elephant", "echo", "flight", "french", "hat", "hour", "ink", "itch", "jinx", "jerk", "lamp", "listen", "mouth", "mice", "market", "never", "knife", "north", "opera", "ounce", "park", "punt", "resist", "run", "rope", "sit", "shelf", "start", "store", "square", "time", "that", "them", "try", "under", "above", "uncle", "usher", "vice", "vote", "work", "when", "winter", "wonderful", "year", "typist", "television", "lazy", "guitar", "water", "sugar", "orange", "rake", "injury", "tissue", "empty", "automobile", "crazy", "happiness", "munch", "crunch", "examine", "burn", "verse", "over", "squint", "squeeze"}
	else
		set the_list to {"Hello, how are you today?", "Gary is a very cool dude.", "Button your flannel shirt.", "The fireplace burned brightly.", "Tonight is all we have.", "Smoke gets in your eyes.", "Let's paint the kitchen purple!", "Milwaukee is the beer capitol.", "Wisconsin is the dairy state.", "Franklin is very near to Milwaukee.", "A penny earned isn't much.", "A nickle equals five cents.", "Two nickles equal one dime.", "I'll have a quarter pounder.", "Can I have a dollar?", "king Henry had headless wives!", "A queen bee is huge!", "Jack sprat ate no fat.", "Ten people ran that way.", "Nine comes right after eight.", "Eight tacos with hot sauce.", "Six feet deep sounds good.", "Five threes is a Yahtzee!", "The dog wants to go for a walk.", "Three little pigs arrested me.", "Two more for the road!", "One is the loneliest number.", "Here's your prize.", "The aspirin is in the medicine cabinet.", "Our army is much bigger.", "Don't eat the poison apple.", "The ace is the highest.", "The grey sky turned blue.", "I want to drive the van next.", "Do my eyes look red?", "Your yellow shirt is dirty.", "Axe doesn't rhyme with bird.", "Is the lawn green yet?", "Black widow spiders scare me.", "Reggie White sacked the quarterback!", "Iraq is nice to visit.", "Iran harbors terrorists no more.", "Bob Dylan wrote excellent lyrics.", "Casper is a friendly ghost.", "The sign is located above the door.", "Please vote for president Bush.", "The exit is that way.", "Don't enter while I'm showering.", "We need new carpeting in here.", "Wash the window with ammonia.", "My zipper is stuck again!", "Jazz music can relax me.", "The buzzard circled our camp.", "This blizzard better stop soon!", "That happened nearly a century ago.", "Circus clowns drive little cars.", "Forty days and forty nights.", "That's enough spaghetti for me.", "Elephants can remember very well.", "Do you hear an echo?", "Flight was a great invention.", "French people hate french fries.", "This knife isn't sharp anymore.", "A compass always points north.", "Good Opera hurts my ears.", "How many ounces was that?", "Don't park in my spot!", "Please don't punt the ball.", "How can you resist me?", "Walk, don't run in here.", "Is that rope tied securely?", "Just sit down and watch.", "The shelf can't hold that.", "Let's start all over again.", "Squirrels store all their nuts.", "Squares can't fit into circles!", "Time is on my side.", "It takes a lot to laugh, but it takes a train to cry.", "Some are smears, and some are spots.", "Al Gore invented the internet.", "Still crazy after all these years.", "Megan wishes she could be cool like Gary.", "Go fly a kite.", "Do chickens have lips?"}
	end if
	repeat
		set chosenWord to some item of the_list
		if practiceList is in {""} then exit repeat
		if practiceOn is in {"off"} then exit repeat
		if practiceLetter is in chosenWord then
			set practiceletterstring to "It's time to practice the letter " & practiceLetter & "."
			exit repeat
		end if
	end repeat
	giveWord()
end getlevel

Even if you can’t see where my error is coming from, I appreciate all the help you’ve given
-G

With regards to a long posting, and for your own sanity in developing a script, it is often convenient to place long strings and lists into variables so that you can seperate script data from script logic:


	repeat
		if wpm < 6 then ¬
			set the chosenWord to some item of fourLetterWords as string

Also, note that the “as string” statement in the above isn’t nesseaary, as every item of your list is indeed as string.

Try this:


on getlevel()
	
	if (wpm > 24) then
		set chosenWord to some item of list25wmp
		
	else if (wpm > 14) then
		set chosenWord to some item of list15wmp
		
	else if (wpm > 9) then
		set chosenWord to some item of list10wmp
		
	else if (wpm > 5) then
		set chosenWord to some item of list6wmp
		
	else
		set chosenWord to some item of list0wmp
	end if
	
	if (practiceList is not "") or (practiceOn is not "off") then
		
		set practiceletterstring to ¬
			"It's time to practice the letter " & ¬
			practiceLetter & "."
		
	end if
	
	giveWord()
	
end getlevel

P.S. This is a very cool script, by the way, a lot of fun! Using “display dialog” for timed typing tests is very clever. It occurs to me that this same technique could be used for other things as well, like math flash-cards, etc. Good stuff. :slight_smile:

Yeah, it seems to be a good Idea, and I’m extremely close to a finished product that runs with all the features I want. Unfortunately, besides the ‘Stack overflow’ error that occurs now n’ then, I just had another error where it just seemed to get stuck with no alert letting me know what happened. Both you guys showed me some ways to clean-up the script, so I’ll give that a try and see what happens. It’s funny that I’m typing this entire “Typing Practice” script with two fingers. I better hurry-up and get this thing running correctly! :?