xcode & interface builder..weird scripts

Maybe i’m confused, maybe i’m a noob, maybe it’s just because i haven’t slept, but…

I can’t get my script to run in xcode once I have it associated with a button. In interface builder I mark that I want the “Action/Clicked” and make a new script. The script runs normally without the “on «event coVScliI» theObject / end «event coVScliI»” Once those events are there it always says " expected end but got property" Any help is greatly appreciated

on «event coVScliI» theObject

property AddressFile : alias ((path to home folder as Unicode text) & "iplist1.txt")

try
	read AddressFile
	set AddressList to paragraphs of result
	
	repeat with thisAddress in AddressList
		do shell script "/usr/bin/rsync -a -e ssh --delete ~/Music/iTunes/ music@" & thisAddress & ":~/Music/iTunes/;" & ¬
			"ssh music@" & thisAddress & " 'killall iTunes; ~/Desktop/ituneslaunch.app/Contents/MacOS/ituneslaunch'"
	end repeat
on error errorMsg number errorNum
	«event panSdlog» "Error (" & errorNum & "):" & return & return & errorMsg given «class btns»:"Cancel", «class dflt»:1, «class disp»:caution
end try


end «event coVScliI»

thanks

Colin, properties must go at the top of the script. (Technically, top of a script object.) Either move that line up there, or get rid of it and replace the read command:

read alias ((path to home folder as Unicode text) & "iplist1.txt")

Alternatively, you could go all out and make this a preference that can be changed later; However, I’ll leave that decision up to you. :wink:

Hi Bruce,

I’ve tried the two following methods… both return NSInternal Script Errors when i do a build and run. Compiles fine though… What am i doing wrong? Thanks a million :slight_smile:



on «event coVScliI» theObject
	
	
	try
		read alias ((path to home folder as Unicode text) & "iplist1.txt")
		set AddressList to paragraphs of result
		
		repeat with thisAddress in AddressList
			do shell script "/usr/bin/rsync -a -e ssh --delete ~/Music/iTunes/ music@" & thisAddress & ":~/Music/iTunes/;" & ¬
				"ssh music@" & thisAddress & " 'killall iTunes; ~/Desktop/ituneslaunch.app/Contents/MacOS/ituneslaunch'"
		end repeat
	on error errorMsg number errorNum
		«event panSdlog» "Error (" & errorNum & "):" & return & return & errorMsg given «class btns»:"Cancel", «class dflt»:1, «class disp»:caution
	end try
end «event coVScliI»



property AddressFile : alias ((path to home folder as Unicode text) & "iplist1.txt")

on «event coVScliI» theObject

try
   read AddressFile
   set AddressList to paragraphs of result
   
   repeat with thisAddress in AddressList
       do shell script "/usr/bin/rsync -a -e ssh --delete ~/Music/iTunes/ music@" & thisAddress & ":~/Music/iTunes/;" & ¬
           "ssh music@" & thisAddress & " 'killall iTunes; ~/Desktop/ituneslaunch.app/Contents/MacOS/ituneslaunch'"
   end repeat
on error errorMsg number errorNum
   «event panSdlog» "Error (" & errorNum & "):" & return & return & errorMsg given «class btns»:"Cancel", «class dflt»:1, «class disp»:caution
end try


end «event coVScliI»

thanks again