Results 1 to 3 of 3
  1. #1
    Applescript that speaks the temperature
    This little script gets the current temperature from app WeatherCat.
    All works well except that it often tells me the temperature out to 6, 8 or 10 decimal places.
    I would like it to stop at 1 decimal place even it the temperature is exactly a number with no decimal places.

    Of course I am a no nothing about apple script.

    Any help would be appreciated.


    tell application "WeatherCat"
    set oldCurrentTemperature to 40
    repeat
    set currentTemperature to ExternalTemp
    if oldCurrentTemperature is not currentTemperature then
    tell current application
    say "Current temperature is"
    say currentTemperature as string
    end tell
    end if
    set oldCurrentTemperature to currentTemperature
    delay 60
    end repeat
    end tell

  2. #2
    Applescript that speaks the temperature
    Mark FX's Avatar
    Member Since
    Aug 13, 2011
    Location
    West Sussex, UK
    Posts
    200
    Rep Power
    9
    I don't have the WeatherCat app myself, and so don't know about it's features.
    But I'm assuming that the "ExternalTemp" command returns an AppleScript real number data type.
    Is that correct ?

    If indeed the WeatherCat app is returning a real number, then you have to modify the real number to the decimal places you want, before passing it to the "say" AppleScript command.
    If you need a method for rounding AppleScript real decimal numbers, then I will post a simple method for this if that is what you require.

    Your repeat loop does not appear to have an end, and will run until you quit the Script.
    Was that your intention ?

    I would also consider splitting your AppleScript code into separate methods, in order to make the code more readable and extendable.
    Perhaps consider one method for retreiving the ExternalTemp, and another for rounding the returned real number, and another for speaking the results.

    Regards Mark

  3. #3
    Applescript that speaks the temperature
    pm-r's Avatar
    Member Since
    Oct 16, 2010
    Location
    Brentwood Bay, BC, Canada
    Posts
    12,564
    Rep Power
    20
    It seems there's already an app that can do that using a different source:
    http://www.machsoftwaredesign.com/weather.html

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. My Mac speaks to me when coming out of sleep. I think it's French.
    By GratefulDean in forum macOS - Operating System
    Replies: 4
    Last Post: 09-27-2012, 03:11 PM
  2. Lodsys Speaks Out About iOS In-App Purchase Threats
    By OneMoreThing... in forum Apple Rumors and Reports
    Replies: 0
    Last Post: 05-16-2011, 10:32 AM
  3. I want to RECORD/burn what my Mac speaks, possible?
    By Tanner31593 in forum macOS - Operating System
    Replies: 12
    Last Post: 01-14-2008, 06:58 PM
  4. Replies: 8
    Last Post: 03-03-2005, 03:00 PM
  5. Apple CFO Speaks about current,future finances
    By schweb in forum Apple Rumors and Reports
    Replies: 2
    Last Post: 04-17-2003, 03:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •