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