title: GAS - Wait until user enters data before function continues
body: <p>I'm just starting with GAS so I would appreciate any insight and apologize if this is an obvious question. I am trying to implement a date picker so that a user can choose some dates instead of typing them out. I do this using the code from this question:</p>
  
  <p><a href="https://stackoverflow.com/questions/24841089/returning-a-value-using-date-picker-in-htmlservice-google-apps-script">Returning a value using Date picker in HTMLService / Google Apps Script</a></p>
  
  <p>This works great, but my issue is that the rest of my code continues to run before the user can input dates. The function to call the html is:</p>
  
  <pre><code>function showDialog() {
    var html = HtmlService.createHtmlOutputFromFile('dateDialog')
      .setSandboxMode(HtmlService.SandboxMode.IFRAME);
    SpreadsheetApp.getUi() 
      .showModalDialog(html, 'Please provide a Date Range');
    Logger.log("HTML return = %s", html.getContent());     
    return html.getContent();
  }
  </code></pre>
  
  <p>And I call this from my main script file below. The picker shows up but then the rest of my code continues to execute. In this case, I have a msgBox that pops up and closes the datepicker.</p>
  
  <pre><code>function runthis(){
    var a = showDialog();
    Logger.log(a);
  
    //rest of code would go here
    Browser.msgBox('hello world');
  }
  </code></pre>
  
  <p>I guess I could loop some timeout or pause until the html has returned values but this seems unnecessary. What am I doing wrong? Thanks for any help.</p>