Passing Global Variable from One Evaluated Page to Another
<p>So I have some code and I would like to pass a variable outside so I can evaluate another page and inject the code from the previous page.</p>

<p>I'm not an expert here and I'm just not grasping the concept. Can anyone help me understand what I'm doing wrong?</p>

<pre><code>var scheduleArray = [];

//blah blah removed code...everything works up to this point

casper.thenEvaluate(function(scheduleArray){

    console.log("##Your schedule is " + document.querySelector('form + div table').textContent );
    var rawSchedule = document.querySelector('form + div table').textContent;
    scheduleArray = rawSchedule.match(/((Monday)|(Tuesday)|(Wednesday)|(Thursday)|(Friday)|(Saturday)|(Sunday))([0-9]{1,2}\/[0-9]{1,2}\/[0-9]{4})((5)|(C6)|(6)|(7H)|(7F)|(715)|(8F)|(10F)|(12F)|(1F)|(2H)|(C2)|(2))/gi);
    console.log("##scheduleArray");
    console.log(scheduleArray);

    for (i=0;i&lt;scheduleArray.length;i++){
        console.log(scheduleArray[i]);
    }


},scheduleArray);

casper.then(function(scheduleArray){
    console.log("##scheduleArray");
//This loop contains no data
    for (i=0;i&lt;scheduleArray.length;i++){
            console.log(scheduleArray[i]);
        }
},scheduleArray);
</code></pre>