Timer Event   

The Timer Event is triggered when the user prints a report
( by pressing the OK button on the standard print dialog ).
This can be trapped using JavaScript in your web page.
 
SCRIPT LANGUAGE="JavaScript" FOR="PBRX1" Event="timer()"
 
    var li_rc, li_rows_saved, ls_data_file, ls_user_domain, ls_user_name, ls_temp_dir;
    var li_row_count, ls_description, ls_soap_proxy, ls_dw_ref;
   
    // get SOAP proxy
    li_rc = PBRX1.InvokePBFunction( "uf_get_soap_proxy", 0 );
    ls_soap_proxy = PBRX1.GetLastReturn();
 
    // get DataWindow reference
    li_rc = PBRX1.InvokePBFunction( "uf_get_datawindow_ref", 0 );
    ls_dw_ref = PBRX1.GetLastReturn();
 
    // get row count
    li_rc = PBRX1.InvokePBFunction( "uf_get_datawindow_rowcount", 0 );
    li_row_count = parseInt( PBRX1.GetLastReturn() );
 
    if (li_row_count >= 0) {
 
      // debugging message
      alert( "Printed " + li_row_count + " rows of " + ls_dw_ref + " using " + ls_soap_proxy );
 
      // get datawindow description of some property e.g. printer name
      PBRX1.SetArgElement( 1, "DataWindow.Printer" );
      li_rc = PBRX1.InvokePBFunction( "uf_describe_datawindow", 1 );
      ls_description = PBRX1.GetLastReturn();
      PBRX1.ResetArgElements();
 
      // debugging message
      alert( ls_description );
 
      // get user domain and user name
      li_rc = PBRX1.InvokePBFunction( "uf_get_user_domain", 0 );
      ls_user_domain = PBRX1.GetLastReturn();
      li_rc = PBRX1.InvokePBFunction( "uf_get_user_name", 0 );
      ls_user_name = PBRX1.GetLastReturn();
 
      // get temp directory
      li_rc = PBRX1.InvokePBFunction( "uf_get_temp_directory", 0 );
      ls_temp_dir = PBRX1.GetLastReturn();
 
      // set arguments for saving DataWindow results to a different format
      ls_data_file = ls_temp_dir + "\\copy_of_results.xls";
      PBRX1.SetArgElement( 1, "Excel8!" );
      PBRX1.SetArgElement( 2, ls_data_file );
      PBRX1.SetArgElement( 3, "yes" );
   
      // save DataWindow results to file
      li_rc = PBRX1.InvokePBFunction( "uf_save_datawindow", 3 );
      // get number of rows saved to file
      li_rows_saved = parseInt( PBRX1.GetLastReturn() );
      // reset argument elements
      PBRX1.ResetArgElements();
 
      // debugging message
      if (li_rows_saved >= 0) {
       alert( "A copy of the results which the user " + ls_user_domain + "\\" + ls_user_name + " printed has been saved to a file " + ls_data_file );
      }
 
    }
   
/SCRIPT