title: Pass variables from javascript to iMacros
body: <p>I want to run an iMacro to save lots of webpages (threads on a forum). I worked this out in VBA, but couldn't make it run the iMacro.</p>
  
  <p>I have now tried javascript. I want to pass some basic parameters (thread number, start page number, number of pages to save, file type) to the iMacro and then have it loop until all the pages are saved. This is what I've come up with so far.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  &lt;!--
  var THRNO = prompt("Enter thread number”);
  var PGST = prompt("Enter page start number”);
  var PGNO = prompt("Enter number of pages to save”);
  var THRNM = prompt("Enter thread name/identifier for files”);
  var FLTP = prompt("Enter save file type”);
  var CNTR = 1
  
  do {
  
  var URLN = "http://www.mysite.co.uk/my-forum/showthread.php?t=" &amp; THRNO &amp; "&amp;page=" &amp;   CNTR
  
  var FLNM = THRNM &amp; ".html"
  
  iimSet("URLN", URLN)
  iimSet("FLTP", FLTP)
  iimSet("FLNM", FLNM)
  
  iimPlay("iMacroUniversal.iim")
  
  CNTR = CNTR + 1
  
  } while (CNTR &lt; PGNO);
  
  //--&gt;
  &lt;/script&gt;
  </code></pre>
  
  <p>The code for my iMacro is</p>
  
  <pre><code>URL GOTO=URLN
  SAVEAS TYPE=FLTP FOLDER=D:\MyFolder FILE=FLNM
  WAIT SECONDS=2
  </code></pre>
  
  <p>When I wrote this as VBA code in Excel, it would take all the parameters and open up the iMacros interface but not run the iMacro itself (no error messages - just nothing happened). Am aware that I am probably mixing and mangling up my coding languages.</p>