title: Callbacks, exports and javascript
body: <p>I don't like to ask a question but I feel I need to know how, or a better way of doing this. I should say first that I'm new to Javascript having done Java before and am new to callbacks as well. I read some other questions, but am still having some difficulty. This is truly horrible.</p>
  
  <p>In rounds.js I have this</p>
  
  <pre><code> exports.getCurrentRound = function(callback) {
  
        exec(header + token + address, function (error, stdout, stderr) {
             sys.print('stdout: ' + stdout);
             rounds = stdout;
  
             if (error !== null)
                 callback(null, err);
             else
                 callback(null, currentRound);
       });
  }
  </code></pre>
  
  <p>In index.js I have this.</p>
  
  <pre><code>var result;
  
      rounds.getCurrentRound( function (err, cr) {
  
          currentRound = cr;
          console.log("the current round is" + currentRound);
  
      });
  </code></pre>
  
  <p>How can i get result to equal something? Hope that makes sense. Keep in mind i'm running windows. And am reluctant to use promises. Whatever that is. I hope I'm not wasting your time too much.</p>
  
  <p>Thanks. </p>
  
  <p>Alternatively if there's a way to just run this synchronously please tell me what it is. I just want to know the proper way of doing this.</p>