Sharing Script

If i build a script that is using URL Access and 24U Interface scripting additions do the people i send the script to have to have the same scripting addition installed on there computer.

yes

Where’s your script. Maybe It can be made generic.

 on open audio_file
	set aValue to 10
	set aBar to create progress indicator with properties ¬
		{name:"Audio Conversion FTP Upload", closeable:true, indeterminate:true, maximum:¬
			100, top message:"Converting Audio.", buttons:{"Cancel"}, size:{300, 100}}
	
	
	
	tell application "iTunes"
		set preferred_encoder to current encoder
		set AAC_encoder to encoders whose name is "AAC encoder"
		set current encoder to item 1 of AAC_encoder
		set NewAudioFile to convert audio_file
		set x to location of item 1 of NewAudioFile --path of audio file converted
		set current encoder to preferred_encoder
	end tell
	set aValue to 33
	update progress indicator aBar current value aValue without indeterminate
	update progress indicator aBar top message "Uploading Converted Audio File."
	
	set fullURL to "ftp://" & "user" & ":" & "password" & "@" & "url"
	try
		tell application "URL Access Scripting"
			upload x to fullURL replacing yes without binhexing
		end tell
		
	on error the_error
		display dialog "FTP:" & the_error buttons {"Quit"} with icon stop
		
		tell application "iTunes" to delete item 1 of NewAudioFile --delete in playlist 
		tell application "Finder" to delete x --move audio file converted to trash
		
	end try
	
	
	set aValue to 80
	update progress indicator aBar current value aValue without indeterminate
	update progress indicator aBar top message "Deleting Converted File."
	
	
	tell application "iTunes" to delete item 1 of NewAudioFile --delete in playlist 
	tell application "Finder" to delete x --move audio file converted to trash
	
	update progress indicator aBar top message "Process Complete"
	
end open


--user input for podcast information

set a_title to my get_validated_input("Sermon Title:", "Sermon Title", {Unicode text, string})

set a_date to my get_validated_input("Enter a date:", "6/8/05", {date}) -->date "Wednesday, June 8, 2005 12:00:00 AM"

set a_time to my get_validated_input("Sermon Time:", "In Minutes", {Unicode text, string})
set a_scripture to my get_validated_input("Scripture Reference:", "John 3:16-25", {Unicode text, string})
set a_Description to my get_validated_input("Description:", "Short Description", {Unicode text, string})

on get_validated_input(the_prompt, default_answer, valid_types)
	--set the error to blank (we don't have an error yet...) and the icon to the standard icon:
	set {the_error, the_icon} to {"", 1}
	repeat
		try
			--get the input from the user using the prompt and default answer supplied
			--in the parameters of the handler:
			set the_result to text returned of (display dialog the_error & the_prompt default answer default_answer buttons {"Cancel", "OK"} default button 2 with icon the_icon)
			--evaluate the user's input; since we accepted a list of valid types
			--we need to iterate through the types:
			repeat with i from 1 to (count valid_types)
				try
					--since the list of valid_types are classes, you can't
					--simply use get the_result as (item i of valid_types) because
					--AppleScript is expecting a class, not a variable
					--to work around this, I create a new script that allows me to
					--pass the class as a string and still get the desired result:
					set valid_result to (run script "get \"" & the_result & "\" as " & (item i of valid_types) as Unicode text)
					--if this is a valid coercion, then return the result:
					return valid_result
				on error
					try
						--some classes don't allow coercions with a "the_result as «class»" command
						--(date is one such class) so you have to use "«class» the_result" if 
						--the first (more common) coercion fails:
						set valid_result to (run script ("get " & (item i of valid_types) as Unicode text) & " \"" & the_result & "\"")
						--if this is a valid coercion, then return the result:
						return valid_result
					end try
				end try
			end repeat
			--if we get to this point, there was no valid coercion and
			--valid_result is not defined so trying to return it
			--will cause an error:
			return valid_result
		on error e number n
			--on the error, do something:
			if n = -128 then return default_answer --user cancelled so just return the default_answer
			--if it wasn't a user cancelled error, and, rather, that there was no valid_result
			--change the error from the default blank to a more descriptive error
			--and use the alert icon to signify a problem and then cycle through
			--the whole process again:
			set {the_error, the_icon} to {("The input "" & the_result & "" is not a valid " & (item 1 of valid_types) as Unicode text) & ". Please try again." & return & return, 2}
		end try
	end repeat
end get_validated_input

--setting the message

set message to a_title & return & a_date & return & a_scripture & return & a_time & return & a_Description & return


display dialog a_title & return & a_date & return & a_scripture & return & a_time & return & a_Description


--generate txt

property storage_file_name : "Podcast_Info.txt"
set file_path to ((path to startup disk) as string) & storage_file_name
set file_ref to open for access file file_path
set eof_posiiton to get eof file_ref

set file_ref to open for access file file_path with write permission
write message & return to file_ref
close access file_ref


set info_file to file_path

try
	tell application "URL Access Scripting"
		upload info_file to fullURL replacing yes
	end tell
	
on error the_error
	set user_input to display dialog "FTP:" & the_error buttons {"Quit"} with icon stop
	deafult
	answer
	message_a
	if button returned of user_input is "Quit" then quit
	
end try