ichat status

HI everyone… I am trying to understand a script I found for setting the display of ichat’s status to your current itunes song…

my questions are:

  1. what is <> – what is the purpose of having a function called this?

  2. same for <> – and why does it have “the object” beside it?

  3. What does Return 15 signify? Is this how long of a time period it waits before it checks the current song’s information? is it 15 seconds?

  4. What is the significance of the last line:
    property ASDScriptUniqueIdentifier : “ZeroStatus.applescript” ?

Thank you for your help…

the code is as follows:

-- ZeroStatus.applescript
-- ZeroStatus

--  Created by Christian Nelson on Sat Mar 06 2004.
--  Copyright (c) 2004 Murder Thoughts Software. All rights reserved.

on «event appSidle»
	tell application "System Events"
		if (exists process "iChat") and (exists process "iTunes") then
			set theBand to "Unknown Artist"
			set theTitle to "Unknown Track"
			try
				tell application "iTunes"
					if player state is playing then
						if the artist of current track is not "" then
							set theBand to artist of current track
							set ichatMessage to theBand
						end if
						if the name of the current track is not "" then
							set theTitle to name of current track
							set ichatMessage to ichatMessage & " - " & theTitle
						end if
						tell application "iChat"
							set status message to ichatMessage
						end tell
					end if
					if player state is not playing then
						if player state is paused then
							set playerState to "paused"
						end if
						if player state is stopped then
							set playerState to "stopped"
						end if
						if player state is fast forwarding then
							set playerState to "skipping forward"
						end if
						if player state is rewinding then
							set playerState to "skipping back"
						end if
						tell application "iChat"
							set status message to "iTunes is " & playerState & "."
						end tell
					end if
				end tell
			end try
		end if
	end tell
	
	return 15
end «event appSidle»
 
on «event appSwilQ» theObject
	try
		tell application "System Events"
			if (exists process "iChat") then
				tell application "iChat"
					set status message to "Available"
				end tell
			end if
		end tell
	end try
end «event appSwilQ»


property ASDScriptUniqueIdentifier : "ZeroStatus.applescript"

ok… so I reworked this script so that I could effectively alternate artist/name with composer/album every 5 seconds…

my question now is… how do I make this more efficient?

its checking the date constantly to compare time by 5 seconds… is there an easier way I can say “come back here in 5 seconds”… without it having to constantly store the date… ?

-patrick


repeat
	set dogfood to false
	tell application "System Events"
		if (exists process "iChat") and (exists process "iTunes") then
			set theBand to "Unknown Artist"
			set theTitle to "Unknown Track"
			try
				tell application "iTunes"
					if player state is playing then
						if the artist of current track is not "" then
							set theBand to artist of current track
							set ichatMessage to theBand
						end if
						if the name of the current track is not "" then
							set theTitle to name of current track
							set ichatMessage to ichatMessage & " - " & theTitle
						end if
						tell application "iChat"
							set status message to ichatMessage
						end tell
					end if
					if player state is not playing then
						if player state is paused then
							set playerState to "paused"
						end if
						if player state is stopped then
							set playerState to "stopped"
						end if
						if player state is fast forwarding then
							set playerState to "skipping forward"
						end if
						if player state is rewinding then
							set playerState to "skipping back"
						end if
						tell application "iChat"
							set status message to "iTunes is " & playerState & "."
						end tell
					end if
				end tell
			end try
		end if
	end tell
	set thedate to (current date)
	set thetime to time of thedate
	set thetimeahead to thetime + 5
	repeat until dogfood
		if thetime = thetimeahead then
			set dogfood to true
		else
			set thedate to (current date)
			set thetime to time of thedate
		end if
		
	end repeat
	set dogfood to false
	tell application "System Events"
		if (exists process "iChat") and (exists process "iTunes") then
			set theBand to "Unknown Artist"
			set theTitle to "Unknown Track"
			try
				tell application "iTunes"
					if player state is playing then
						if the artist of current track is not "" then
							set theBand to composer of current track
							set ichatMessage to theBand
						end if
						if the name of the current track is not "" then
							set theTitle to album of current track
							set ichatMessage to ichatMessage & " - " & theTitle
						end if
						tell application "iChat"
							set status message to ichatMessage
						end tell
					end if
					if player state is not playing then
						if player state is paused then
							set playerState to "paused"
						end if
						if player state is stopped then
							set playerState to "stopped"
						end if
						if player state is fast forwarding then
							set playerState to "skipping forward"
						end if
						if player state is rewinding then
							set playerState to "skipping back"
						end if
						tell application "iChat"
							set status message to "iTunes is " & playerState & "."
						end tell
					end if
				end tell
			end try
		end if
	end tell
	set thedate to (current date)
	set thetime to time of thedate
	set thetimeahead to thetime + 5
	repeat until dogfood
		if thetime = thetimeahead then
			set dogfood to true
		else
			set thedate to (current date)
			set thetime to time of thedate
		end if
	end repeat
end repeat