私は AppleScript の初心者で、タイプライターを購入して山に引っ越すのはもうすぐです。
誰でも、なぜこれが失敗するのか説明してください:
set mah_file to POSIX file "/Users/me/folder/fileinfo.txt"
set mah_data to "some text!!!!!!"
on write_to_file(this_data, target_file, append_data) -- (string, file path as string, boolean)
try
set the target_file to the target_file as text
set the open_target_file to ¬
open for access file of target_file with write permission
if append_data is false then ¬
set eof of the open_target_file to 0
write this_data to the open_target_file starting at eof
close access the open_target_file
return true
on error
try
close access file target_file
end try
return false
end try
end write_to_file
write_to_file(mah_data, mah_file, true)
これは成功しますが:
set mah_file to choose file
set mah_data to "some text!!!"
-- the rest is identical
私はもう試した:
set mah_file to POSIX file "/Users/me/folder/fileinfo.txt" as file
と
set mah_file to POSIX file "/Users/me/folder/fileinfo.txt" as alias
と
set mah_file to POSIX file "/Users/me/folder/fileinfo.txt" as text
AppleScript は、これが機能しない理由をわざわざ教えてくれないので、私は元気で、本当に正気を失っています。