[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

(DTPtechNote:1639) Re: [InDesign CS3][scripting]Event scripting



write_log.applescriptを少し書き換えました。
BOMを何回か上書きしてますけど、やっぱりBOMがないとうまくエディタが判定できない。めんどい。


tell application "Adobe InDesign CS3"
	try
		set return to ASCII character 10 --LF改行
		set doc_name to (name of document 1) as Unicode text
		set my_log to my get_folder_path() & "log.txt"
		set my_log_posix to (quoted form of POSIX path of my_log) as Unicode text
		
		set my_event to evt
		set tmp_str to time stamp of my_event & tab & doc_name & tab & event type of my_event & return
		my write_file(tmp_str, my_log)
	end try
end tell

to get_folder_path()
	tell application "Adobe InDesign CS3"
		set my_script to active script
		tell application "Finder"
			set my_file to file my_script
			return (container of my_file) as Unicode text
		end tell
	end tell
end get_folder_path

-----★ファイル書き出し(追記)
to write_file(str, my_file)
	tell application "Finder"
		set str to str as Unicode text
		set FH to open for access file my_file with write permission
		try
			write ((ASCII character 254) & (ASCII character 255)) to FH --BOMを書き込む
			set my_eof to (get eof FH) + 1
			write str starting at my_eof to FH --as Unicode text
		on error errMsg number errNo
			close access FH
			my my_error("書き込み時のエラーです" & return & errMsg & errNo, true)
		end try
		close access FH
		--update my_file
	end tell
end write_file