This question already has an answer here:
I've got a code that I want to automate, but I'm not sure how. I have a Mathematica notebook that I need to run many times over, each time changing one variable and repeating. My idea was to set up a "parent" notebook with a For loop that changes the variable each time, and the main notebook is called each time inside the For loop. However, I think this involves parallel Mathematica computing, and I'm new to this. I tried to tell the "parent" notebook to Pause while the other notebook is running, but that pauses both notebooks and nothing gets done. Help?!
Here's some example code:
For[i=1,i<7,i++, For[j=1,j<7,j++, (* lots of inputs dependent on i and j *) nb=NotebookOpen["Sanple.nb"]; SelectionMove[nb,All,Notebook]; SelectionEvaluate[nb]; ];];
What I need my code to do is to open Sample.nb, evaluate it for the current i and j, and then wait for that evaluation to be done before moving on to the next i and j. Sample.nb is the core algorithm that I need to run many times (gonna be hundreds), so this loop will definitely help out.