title: Persistant variable in Google Apps Script
body: <p>The following always shows 0 :</p>
  
  <pre><code>var gNumber = 0;
  
  function myTest() {
    Browser.msgBox(gNumber);
    gNumber++;
  }
  </code></pre>
  
  <p>I can, of course, use ScriptProperties or UserProperties to store a value permanently.  Fine for simple values but it will not work for an object unless I stringify it.  But with the latter, I cannot store permanently an object that opens a sheet and lets me manipulate it via methods (get, set).</p>
  
  <p>I have an Orders spreadsheet that uses information from the Customers spreadsheet.  Everytime I check an order, I need to open the Customers spreadsheet and load its data into an array.  Is there a way to keep an object permanently so that I don't need to open Customers over and over again?</p>
  
  <p>By permanently, I mean as long as the sheet associated with the script is open!</p>
  
  <p>Is there a way I can do that?</p>