Results 1 to 2 of 2
  1. #1
    Simple question, If greater than x and less than y, how? #Applescript

    Member Since
    Dec 01, 2008
    Posts
    7
    Simple question, If greater than x and less than y, how? #Applescript
    I recently found speech commands; and might I add, I am in love. Currently scripting a weather command that will relay the weather and suggest a proper dress for my daughter when she is picking out her clothes. Everything works great with the exception of my if-then statements that have to to with being greater than a number and less than another. I personally haven't been able to find anything in regards to combining both greater than and less than, though i am sure its very simple.

    The commented out part is where I am experiencing trouble:
    Code:
    set weather_loc to "/Scripts/weather"
    set weather_spk to ""
    set weather_cur to do shell script (weather_loc & " 48413")
    
    set d to text item delimiters
    set text item delimiters to "F"
    set weather_cur to weather_cur's text items
    set text item delimiters to ""
    tell weather_cur to set weather_cur to item 1 & ({""} & rest)
    set text item delimiters to d
    
    if weather_cur is less than or equal to "32" then
    	set weather_spk to "The temperature is currently a freezing " & weather_cur & " degrees. Suggested dress: multiple, heavy layers."
    end if
    
    --if weather_cur is greater than 32 and less than or equal to 55 then
    --set weather_spk to "The temperature is currently a chilly " & weather_cur & " degrees. Suggested dress: medium layers."
    --end if
    
    --if weather_cur is greater than 55 and less than or equal to 75 then
    --set weather_spk to "The temperature is currently a plesant " & weather_cur & " degrees. Suggested dress: light layers. T-shirt and jeans are acceptable."
    --end if
    
    --if weather_cur is greater than 75 and less than or equal to 85 then
    --set weather_spk to "The temperature is currently a warm " & weather_cur & " degrees. Suggested dress: T-shirt and jeans, shorts optional."
    --end if
    
    --if weather_cur is greater than 85 and less than or equal to 95 then
    --set weather_spk to "The temperature is currently a hot " & weather_cur & " degrees. Suggested dress: T-shirt and jeans. Shorts recommended, tank top optional."
    --end if
    
    if weather_cur is greater than "95" then
    	set weather_spk to "The temperature is currently a blistering " & weather_cur & " degrees. Suggested dress: Tank top and shorts."
    end if
    
    say weather_spk

    To give credit where its due:
    Code:
    Fetches weather reports from Yahoo!
    
    Written by Thomas Upton (http://thomas.fiveuptons.com/),
    with contributions from Chris Lasher (http://igotgenes.blogspot.com/).
    
    This code is licensed under a BY-NC-SA Creative Commons license.
    http://creativecommons.org/licenses/by-nc-sa/3.0/us/

  2. #2
    Simple question, If greater than x and less than y, how? #Applescript

    Member Since
    Mar 30, 2004
    Location
    USA
    Posts
    4,744
    Specs:
    12" Apple PowerBook G4 (1.5GHz)
    I think what you're missing is....
    Code:
    ...
    if weather_cur is greater than 32 and weather_cur is less than or equal to 55 then
    ...

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Simple AppleScript for mail
    By JosCiv in forum OS X - Apps and Games
    Replies: 10
    Last Post: 07-27-2013, 04:09 PM
  2. Simple Applescript
    By unh20050 in forum OS X - Development and Darwin
    Replies: 0
    Last Post: 09-11-2011, 10:07 PM
  3. Simple applescript help
    By Doc Thirst in forum OS X - Development and Darwin
    Replies: 3
    Last Post: 12-30-2009, 03:38 PM
  4. Simple applescript
    By Adam in forum OS X - Apps and Games
    Replies: 0
    Last Post: 03-01-2007, 03:25 PM
  5. Simple AppleScript request...
    By 570thusaag in forum Running Windows (or anything else) on your Mac
    Replies: 0
    Last Post: 02-02-2006, 12:33 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
  •