Best way to pass Variable?

Hi All,

I am uploading to Youtube Automatically using youtube-upload (https://github.com/tokland/youtube-upload) as below:

on run {theRecord}
	
	do shell script "source ~/.bashrc && /usr/local/bin/youtube-upload --title=" & quote & listingStreetNumber of theRecord & ", " & listingCity of theRecord & " " & listingState of theRecord & " " & listingZipcode of theRecord & quote & " --description=" & quote & listingRemarks of theRecord & quote & " --thumbnail /Users/snaplash/Desktop/SNAPLASH_DO_NOT_DELETE/COMPLETED_DO_NOT_DELETE/" & listingMLSProviderPrefix of theRecord & Mlsid of theRecord & "/Branded/" & listingMLSProviderPrefix of theRecord & Mlsid of theRecord & "_POSTER.png /Users/snaplash/Desktop/SNAPLASH_DO_NOT_DELETE/COMPLETED_DO_NOT_DELETE/" & listingMLSProviderPrefix of theRecord & Mlsid of theRecord & "/Branded/" & listingMLSProviderPrefix of theRecord & Mlsid of theRecord & ".mp4; exit;"
	
	set BrandedIdNumber to result as string
	
	set BrandedYoutubeLink to "https://www.youtube.com/embed/" & BrandedIdNumber
	
	
end run

The script gives a result such as BPlj8UOLgNE as the ID number

What is the best most efficient way to pas this variable to another script?

I was thinking it may just be better to output to a txt file?

do shell script "echo " & BrandedYoutubeLink & " > /Users/snaplash/Desktop/SNAPLASH_DO_NOT_DELETE/PROCESSING_DO_NOT_DELETE/BrandedYTID.txt"

Is this the best way to approach this as I will always know the file name?

set BrandedYoutubeLink to (do shell script "cat /Users/snaplash/Desktop/SNAPLASH_DO_NOT_DELETE/PROCESSING_DO_NOT_DELETE/BrandedYTID.txt | xargs echo")

display dialog BrandedYoutubeLink

Any opinions will be most welcome!

Depends on when the other script is called.

Synchronously
When the other script is called by the upload script you can pass variables as an list to the run handler.

script myCount
	on run argv
		return count of argv
	end run
end script

run script myCount with parameters {1, 2, 3, 4}

on the command line you can send multiple parameters just by adding more arguments to the command line but all parameters are strings. When script myCount is saved in myCount.scpt you can call it like:

[format]osascript myCount.scpt 1 2 3 4[/format]

Asynchronously

If the script is called by any script and at any given time it’s indeed better to store it in a file at an know location. It’s much more like shared script data than passing a variable. The examples you wrote are perfectly fine. You can read and write data to files many different ways using the shell, osaxen, cocoa or other application but they’re doing all the same thing; using the kernel to read and write data to disk.

Thank you so much for the advice!

Yes my scripts run in separate widgets.

I didnt know if writing to file may be a bit clunky, but it seems less clunky than passing info.

Thank you its appreciated!~