title: Working with "Out" Parameters in JavaScript
body: <p>I am working with an ActiveX control in Internet Explorer 8 that is to display a save file dialog which let's the user choose a file name and file type (jpg, gif, etc).  These values get passed to code and then are used in a different method to save the file.  Unfortunately the method that invokes the dialog has no return value, and the file name and file type are passed in as <em>out</em> parameters.</p>
  
  <p>The signature of the method (expressed in Visual Basic) looks like this:</p>
  
  <pre><code>Public Sub SaveFileDialog( _
     ByVal bstrDialogType As Variant, _
     ByRef pbstrFileName As String, _
     ByRef out_pvType As Long _
  )
  </code></pre>
  
  <p>The two <em>ByRef</em> parameters are the <em>out</em> parameters.</p>
  
  <p>I have written the following JavaScript code:</p>
  
  <pre><code>try
  {
      var saveFileName, saveFileType; // out variables
      gxVideoPlayBack.SaveFileDialog("image", saveFileName, saveFileType);
      alert(saveFileName); // displays "undefined"
      alert(saveFileType); // displays "undefined"
  }
  catch(error)
  {
      if(!error.number === -2147221484) // User clicked cancel.
      {  
          alert(error.message);
      }
  }
  </code></pre>
  
  <p>The code works in that the ActiveX control produces its dialog, and I can handle error conditions, but <strong>I can't seem to figure out how to capture the values of the <em>out</em> parameters.</strong></p>
  
  <p>In the code <em>gxVideoPlayBack</em> is a reference to the ActiveX control embedded in the DOM via an HTML  element.</p>
  
  <p>If JavaScript will not work for this, can it be done in VBScript?</p>
  
  <p>As an alternative I can just implement my own dialog, but would rather use the one provided.</p>