title: Temporary file of AppleScript
body: <p>I want to use AppleScript to create a temporary file and then extract the text from it.
  This is the code written by someone else, but I don't understand it at all. Is there a simpler one?</p>
  <pre><code>set AppleScript's text item delimiters to &quot;&quot;
  set tmpfile to ((path to temporary items folder as string) &amp; &quot;Pashua_&quot; &amp; (characters 3 thru end of ((random number) as string)) as string)
      
  set fhandle to open for access tmpfile with write permission
  write (config as string) to fhandle as «class utf8»
  close access fhandle
      
  set posixtmpfile to POSIX path of tmpfile
  </code></pre>
  <hr />
  <p><strong>Result</strong></p>
  <ol>
  <li><p>How use the <code>Applescript</code> get <strong>Temporary folder?</strong></p>
  <p>Use Command: <code>(path to temporary items folder as string)</code>.</p>
  </li>
  <li><p>You must use the “open for access” command (not open ), otherwise the program will not create a temporary file, and will report an error. This action is like vim: create a new file, if you don’t</p>
  </li>
  <li><p>&quot;open for access&quot; needs to add &quot;with write permission&quot; to support write operations</p>
  </li>
  <li><p>How many times have you performed the &quot;open for access&quot; operation, how many times must you perform the &quot;close access&quot;. Just like &quot;open up memory &amp; clean up memory&quot; in other languages</p>
  </li>
  <li><p>The temporary file still needs to be deleted, because even if I execute &quot;close access&quot;, the file still exists. So the &quot;temporary file&quot; does not seem to exist</p>
  </li>
  </ol>
  <p><strong>End</strong></p>