I am wondering what exactly are the differences in using
to evaluate cells in a given notebook.
In particular, I am referring to the discussion: Evaluate Initialization Cells of another notebook. Given my new status here, I couldn't see how I could continue with that conversation directly, so I decided to post a new queston.
The comments in the referenced question proposed these two solutions to the problem:
filename = SystemDialogInput["FileOpen"]; NotebookEvaluate[filename, EvaluationElements -> "InitializationCell"]
filename = SystemDialogInput["FileOpen"]; nb = NotebookOpen[filename]; FrontEndExecute[FrontEndToken[nb, "EvaluateInitialization"]]; NotebookClose[nb]
I am trying to solve the same problem. Taken at face value, it seems both approaches are valid. Are there any subtleties that make one preferred to the other, issues of scope/context, etc.?
NotebookEvaluatereturns the last expression evaluated. Also, to make them more comparable you may have to add