Problem with Ford's "AppleScript Studio Programming..."

Joined
Jan 5, 2007
Messages
1
Reaction score
0
As an experienced Objective-C programmer, but a complete beginner with AppleScript Studio, I'm stumped on page 57. My test program, "Fortune Teller" compiles and begins to run, but when I enter a question, "What's up, doc?" and push the "Ask" button, I get an alert:
AppleScript Error
NSReceiverEvaluationScriptError: 4(1)

Duh! What do I do now?
--rollos <[email protected]>
 
Joined
Jan 26, 2007
Messages
1
Reaction score
0
Hi Rollos, I know you posted that two weeks ago but I've only just seen your post.

It's nothing you've done that's causing the script to fail- there are huge holes in what the book is telling you (that you'll notice if you keep working through it).

If I'm honest I'm amazed the book was published in the state its in- and you may have noticed if you go onto the website to download the sourcecode (as advised within the book) it downloads a WINDOWS executable. For a book on MAC OS PROGRAMMING.

Thanks.

Anyway back to your question- the problem with the script as it stands is that:

1 - neither the main window, nor the text field, are defined as having anything to do with the applescript,
2 - neither are named.

what you need to do is go to Interface Builder and click anywhere on the main window. Select the inspector window from the tools menu. On the dropdown at the top of the inspector window select Applescript. In the Name field type "Main", and then click the checkbox for xxxx.applescript at the bottom of the window (where xxxx is your script name- most probably 'Fortune Teller' or something like that.

then, go back to your window and, this time, click the text box. On the inspector window, go to Applescript and type 'textbox' as the name and, once again, click the xxxx.applescript at the bottom of the inspector.

Now hopefully your script should work (I don't have Xcode in front of me right now so I hope I've not missed anything- let me know if it works).

Also I hope you can see from what we've done, what was missing. Everything has to link in Applescript Studio- and you'll notice in Ford's script he has

'.... contents of text field "textbox" of window "main" ....' but he doesn't explain the need to name the text field or window- and nor does he link them to any Applescript event. The error you're receiving is from the script not knowing what to do with the 'set question to....' line.

Anyway good luck - Applescript Studio is a superb (and fun) way to make Apps so it's worth persevering. It does, also, deserve a much better book that Ford's to open it up to people.

Jamie.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top