New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

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


Post Reply New Thread Subscribe

 
Thread Tools
aaon

 
Member Since: Dec 01, 2008
Posts: 7
aaon is on a distinguished road

aaon is offline
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/
QUOTE Thanks
technologist

 
Member Since: Mar 30, 2004
Location: USA
Posts: 4,744
technologist has a reputation beyond reputetechnologist has a reputation beyond reputetechnologist has a reputation beyond reputetechnologist has a reputation beyond reputetechnologist has a reputation beyond reputetechnologist has a reputation beyond reputetechnologist has a reputation beyond reputetechnologist has a reputation beyond reputetechnologist has a reputation beyond reputetechnologist has a reputation beyond reputetechnologist has a reputation beyond repute
Mac Specs: 12" Apple PowerBook G4 (1.5GHz)

technologist is offline
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
...
QUOTE Thanks

Post Reply New Thread Subscribe


« OSX Hardware information | new to objective c - help with tiny problem »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

All times are GMT -4. The time now is 09:15 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?