Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Generally, if you want to do anything with a file or folder, it must be a complete <code>alias</code> reference. Just change <code>as file specification</code> to <code>as POSIX file as alias</code> and that part will work! </p> <p>Also, remove the <code>as list</code> and delete the line <code>set eof of the_file to 0</code>. Assuming the file already contains information, you're basically telling the script that the end of the file is the beginning of the file.</p> <p>I hope this helps!</p> <p><strong>EDIT:</strong> I don't know why your code isn't working properly (it does for me). Well, I guess you could try the following (kind of hacky, though, but oh well :P )</p> <pre><code>tell application "Finder" try set the_file to "/Users/xxxx/Documents/outputvals.txt" as POSIX file as alias on error --file doesn't exist yet, so create it set the_file to (make new document file at ("/Users/xxxx/Documents/" as POSIX file as alias) with properties {name:"outputvals", text:""}) --Normally, when you're creating documents in this fashion, you would put the text you want in the document after the 'text' property, but for your sake I will use the alternative :) end try end tell set the_data to costItems try open for access the_file with write permission write the_data to file the_file starting at eof close access the_file on error --you never know when errors will crop up (when it comes to reading and writing files); better to be safe than sorry try close access the_file end try end try </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload