I am new to programming and am trying to design a Fortune Teller game according to a book "Applescript studio programming for the absolute beginner".
When the player types the question in the Text Field and then clicks the "Ask" button, the program will randomly give the answer "Yes" "No" "Maybe".
I did as the book instructed. But when I press build and go in Xcode, it returns "2018-04-08 22:22:01.189 Fortune Teller[14813:245050] *** -[AppDelegate clicked:]: Can’t get every text of TextField of class "NSObject". (error -1728)"
Can anyone tell me how to fix that problem? Thank you!
The following is the interface.
The following is the code.
-- This code runs whenever the player clicks on the Ask button on clicked_(theObject)
-- Assign the text entered by the player clicks on the Ask button set the question to contents of text field "textbox" of window "main"
-- Display an error message if the player did not enter any text if question = "" then display dialogue ¬ "Sorry, but you did not ask a question. Please try again."¬ buttons {"OK"} return end if -- Assign a random number between 1 and 3 to a variable named random set randomNo to a random number from 1 to 3
if randomNo = 1 then set answer to "Yes" end if
if randomNo = 2 then set answer to "No" end if
if randomNo = 3 then set answer to "Maybe" end if
beep -- Play a beep sound to get player's intention
display display dialog "Question:" & question & "Answer:" & answer & buttons {"OK"} end clicked_