• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Question on a script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question on a script


  • Subject: Re: Question on a script
  • From: "Mark J. Reed" <email@hidden>
  • Date: Thu, 17 Jan 2008 20:29:30 -0500

On Jan 17, 2008 7:03 PM, Stockly, Ed <email@hidden> wrote:
> Here's how I would do this....

I inadvertently replied directly to Ed instead of to the list . . .

Ed's script works if you want to log all the temps whenever any of
them changes, which matches the output of the original script.  I
interpreted the request differently and came up with this, which only
logs the temp(s) that changed:

property Labels : {"Outside", "Upstairs", "Downstairs", "Main Floor"}
property PreviousValues : {0, 0, 0, 0}
property CurrentValues : {0, 0, 0, 0}

repeat
	set item 1 of CurrentValues to (value of "Temperature Outside.web") as integer
	set item 2 of CurrentValues to (value of "Temperature Upstairs.web") as integer
	set item 3 of CurrentValues to (value of "Temperature
Downstairs.web") as integer
	set item 4 of CurrentValues to (value of "Temperature Main
Floor.web") as integer
	repeat with index from 1 to count (CurrentValues)
		if item index of CurrentValues is not equal to item index of
PreviousValues then
			log (item index of Labels) & ":" & item index of CurrentValues
		end if
	end repeat
	set PreviousValues to CurrentValues
       delay 30
end repeat


> ------------
> -- read current temperatures
> set new_Outside to (value of "Temperature Outside.web") as integer
> set new_Upstairs to (value of "Temperature Upstairs.web") as integer
> set new_Downstairs to (value of "Temperature Downstairs.web") as integer
> set new_Main_Floor to (value of "Temperature Main Floor.web") as integer
> -- compare to stored values
> set UpdateLog to false
> repeat
>     if (new_Outside is not equal to Temp_Outside) then set UpdateLog to true
>     if (new_Upstairs is not equal to Temp_Upstairs) then set UpdateLog to
> true
>     if (new_Downstairs is not equal to Temp_Downstairs) then set UpdateLog
> to true
>     if (new_Main_Floor is not equal to Temp_Main_Floor) then set UpdateLog
> to true
>     if UpdateLog then
>         write (log ("Outside: " & new_Outside & " Upstairs: " &
> new_Upstairs & " Downstairs: " & new_Downstairs & " Main floor: " &
> new_Main_Floor))
>         -- update stored values
>         set Temp_Outside to new_Outside
>         set Temp_Upstairs to new_Upstairs
>         set Temp_Downstairs to new_Downstairs
>         set Temp_Main_Floor to new_Main_Floor
>     end if
> end repeat
>
> -------------
> ES
>
>  _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> AppleScript-Users mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> Archives: http://lists.apple.com/archives/applescript-users
>
> This email sent to email@hidden
>



--
Mark J. Reed <email@hidden>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Re: Question on a script (From: "Stockly, Ed" <email@hidden>)

  • Prev by Date: Re: Get only the name of the file, instead of the whole path!
  • Next by Date: Re: Get only the name of the file, instead of the whole path!
  • Previous by thread: Re: Question on a script
  • Next by thread: Re: Parsing Strings
  • Index(es):
    • Date
    • Thread