Hey! I am trying to use applescript to write the current track name and artist to a file. The idea is that applescript will repeat this every 30 seconds and then the file can be picked up by various other applications to be used in mail sigs, forum sigs, blog entries… etc, (normally by applescripts, shell scripts, or php) automatically.
However, there are two problems:
1- if I try and put repeat at the top, it will not run / ‘compile’, it only looks as far as ‘to writeToThisFile("iMon…’, and then says: “Syntax error: Expected ‘end’ but found ‘to’” I want it to repeat the whole script, not just the first few lines.
2- If I remove this and simply try to open the file, it ‘compiles’ but on runtime it says: “Applescript error: File file iMonkey:Users:radicaledward:MyApps:iTunesData.mk is already open”… which is odd because I tried to adjust for sort of error using lines 13 to 15.
Sorry about the noobishness, I only really have background knowlege :P. Any helps would be awes0me, thanks in advance.
—Code-(With numbering)-------------------
00 (iTunesey monkey :P:P -Radical Edward)
01
02 (Get current track info from iTunes)
03 try
04 tell application “iTunes” to set _monkey to name of current track & " - " & artist of current track
05 on error
06 set _monkey to “Silence :P:P”
07 end try
08
09 (Write this to a file)
10 writeToThisFile(“iMonkey:Users:radicaledward:MyApps:iTunesData.mk”)
11
12 to writeToThisFile(_fileName)
13 try
14 close access _fileName
15 end try
16
17 set _fileName to (_fileName as file specification)
18 open for access _fileName with write permission
19 set eof of _fileName to 0
20 write (_monkey) to _fileName starting at eof
21 close access _fileName
22 return true
23 end writeToThisFile
delay “30”
—End Code--------------------------------
—Code-(To copy)-----------------------
(iTunesey monkey :P:P -Radical Edward)
(Get current track info from iTunes)
try
tell application “iTunes” to set _monkey to name of current track & " - " & artist of current track
on error
set _monkey to “Silence :P:P”
end try
(Write this to a file)
writeToThisFile(“iMonkey:Users:radicaledward:MyApps:iTunesData.mk”)
to writeToThisFile(_fileName)
try
close access _fileName
end try
set _fileName to (_fileName as file specification)
open for access _fileName with write permission
set eof of _fileName to 0
write (_monkey) to _fileName starting at eof
close access _fileName
return true
end writeToThisFile
delay “30”
—End Code-----------------------------
EDIT: I redid this script using a subroutine from ADC, and I still can’t get it to work < >_< >!! I am getting vewy vewy SLEEEPAH! So pleash help, thank you :P:P, PS if you want this new code (it doesn’t work BTW), just ask.