I’m new to Applescript so I thought I would start out with the Currency Converter Tutorial in the Applescript Studio Programming Guide. I completed the exercise but my script is not working correctly.
the code is (from page 114):
on clicked theObject
tell window of theObject
try
set theRate to contents of text field “rate” as number
>>>set theAmount to contents of text field “amount” as number<<<
set contents of text field “total” to theRate * theAmount
on error
set contents of text field “total” to 0
end try
end tell
end clicked
The variable theRate works correctly but the variable theAmount is failing because it is not defined. I thought it may be a scoping issue so I defined the variable theAmount as a global but it changed nothing. I double checked the name of the control. The problem is with the “contents of text field “amount” as number” is not returning a value. Why? What basic element am I missing?
the AppleScript Code is not the problem.
Please check your connections in Interface Builder against the connections of the given example.
I’m sure, there’s a reference (like a name) missing
I couldn’t find a name missing but I did get a little further down the trail. The issue seems to be the number formatter. When I delete it, the calculation works. When I add the Number Formatter and set to Currency, the conversion fails. I’m dragging the Number Formatter on to the text box and setting the Style to Currency. Is there some secret to setting up the Number Formatter?