title: Can I put shared applescript code in a separate file and load it in various scripts?
body: <p>I'm starting to poke around with Applescript and am looking at writing a few scripts for managing windows.  A common task they will all need is to get the current screen size.</p>
  
  <p>I've created a screen_size subroutine that seems to work, and I want to be able to share that with all my scripts.  However, I can't figure out a way to put that in a separate file that I can load in my other scripts.  I tried creating a separate screen_size.scpt file and use <code>load script "screen_size.scpt"</code>, but I get an error about "can't make "screen_size.scpt" into a type file".</p>
  
  <p>There has to be a way to do this, but I haven't been able to find anything online about how to do it.</p>
  
  <p>EDIT:</p>
  
  <p>The POSIX stuff suggested isn't working for me.  I'm able to create the file object, but it refuses to convert to an alias, saying it can't find the file (looks like the POSIX file stays relative instead of expanding fully).</p>
  
  <p>I found a suggestion online to use Finder, and have gotten the following working to get an alias:</p>
  
  <pre><code>tell application "Finder"
    set _myPath to container of (path to me) as text
  end tell
  
  set _loadPath to (_myPath &amp; "screen_size.scpt")
  set _loadAlias to alias _loadPath
  </code></pre>
  
  <p>However, the next line fails with a syntax error, claiming that _loadAlias isn't a variable:</p>
  
  <pre><code>property _ScreenSize : load script _loadAlias
  </code></pre>
  
  <p>Every variation of this I've tried (doing the alias in the load call, etc) fails, always claiming the variable doesn't exist, even though I know it's being set and working as I can display it.  What's going on?  Why is it claiming a variable doesn't exist when it obviously does?</p>