New answers tagged

3

Probably you should use NotebookEvaluate instead of SelectionEvaluate. According to the Documentation, By default, NotebookEvaluate evaluates the cells of a notebook in the same way that Get evaluates the lines of a package file. For example try: nb = CreateDocument[ExpressionCell[Defer[Pause[10]], "Input"]]; NotebookEvaluate[nb] Print["!"] The ...


1

A useful principle in using the Wolfram Language: Remove values you assign to variables as soon as you finish using them. See Defining Variables. How to Work with Variables and Functions Variables and functions are integral to the Wolfram Language's symbolic programming language. These "How tos" give step-by-step instructions for common tasks related to ...


2

If you're willing to accept output cell indices being different, and semi-colon-suppressed output not being captured, ToExpression[#, StandardForm, Defer]& @@ NotebookRead @ Cells[CellStyle -> "Output"][[i]] should suffice. If output cell indices are to be the same as if input cells were evaluated sequentially from beginning to end of the notebook, ...


5

As commented by J. M. you can persistently increase the menu size with: SetOptions[$FrontEnd, "NotebooksMenuHistoryLength" -> 20] (* 20 is arbitrary *) You can extract a list of Notebook locations with: NotebooksMenu /. Options[$FrontEnd] // MapAt[ToFileName @@ #[[1, ;; 2]] &, {All, 2}]


3

I think this question is a mistake from my side but I also think this answer may be useful for future visitors. testing involves low level notebook programming It seems I was just expecting from this to be too forgiving, if you make your functions self contained, independent from EvaluationNotebook[], it will work quite fine. Module[{nb, oCell}, nb = ...


7

A modification of the answer provided by Kuba that uses an AttachedCell to give the hint: Button[ "Show hint", With[{box = EvaluationBox[]}, SelectionMove[box, All, Expression]; FrontEndExecute@FrontEnd`AttachCell[box, Cell[BoxData[GridBox[ { {Cell["You can plot a function using:", "Text"]}, {Cell[BoxData["Plot[Sin[x],{x,0,1}...


7

How about FlipView: FlipView[{ Button@"Show hint", Column[{ TextCell[ "You can plot a function using:", "Notebook", "Text" ], ExpressionCell[ Defer@Plot[Sin[x], {x, 0, 1}], "Notebook", "Input" ] }] }] alternatively, born from comments under Karsten's answer: FlipView[{ Button["Show hint"], Tooltip[ ...


1

TabView[{"Question" -> "What is a guppy?", "Hint" -> "Think about fish", "Answer" -> InputField["", String, FieldHint -> "Enter your answer"]}] or MenuView[{"Question" -> "What is a guppy?", "Hint" -> "Think about fish", "Answer" -> InputField["", String, FieldHint -> "Enter your answer"]}]


2

Just as an example, I created two files under the same folder, one named "run.nb" which is the file I'll want to evaluate for multiple times, another is "run1.nb" that controls the running process. In "run.nb", I wrote: A = 1; AppendTo[B, A^2]; So what I'll change each time is the input value of A and What I would love to collecto is the value of B. In "...


3

I recommend and use cell tags for quickly locating blocks of code in a notebook. To find and move to a tagged block I do not use the general search dialog as others have suggested. Mathematica automatically builds a nice index of the tags in the Cell menu and I use that.


0

Instructions for adding line numbers in Workbench: http://reference.wolfram.com/workbench/index.jsp?topic=/com.wolfram.eclipse.help/html/tasks/linenumbering.html In notebooks... On Mac: Cmnd+1 through cmnd+9 provide styles that you can use to help make your code easier to grok by collaborators. Cell tags let you name cells and jump back to them (cmnd+j)...


2

You can Get the palette, then apply MakeExpression in order to convert boxes into the corresponding high-level expression, and then display the result as InputForm. For example: palette = Get@ FileNameJoin[{$InstallationDirectory, "SystemFiles", "FrontEnd", "Palettes", "SlideShow.nb"}]; InputForm @@ MakeExpression[palette, StandardForm] If you ...


1

Actually I think you can use NotebookGet to get the code of the palettes. With only your notebook and palette opened, Using NotebookGet@Notebooks[][[2]] can get you the expression form, if that's what you need. But the problem is that this result, just like other outputs of NotebookGet, is full of Cell or CellBox or so, actually still hard to read. But the ...



Top 50 recent answers are included