Hot answers tagged

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[ ...


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}]


4

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 ...


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 = ...


3

Alternatively, if you want to use Mathematica, then you can do something like so-- dir="path/to/directory"; SetDirectory[dir]; fn = FileNames[]; (* select just .nb files, so you don't import and other files, etc. *) notebooks = StringCases[fn, ___ ~~ ".nb"] // Flatten; (* select the notebooks that you want *) Select[ notebooks, StringMatchQ[ ...


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.


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 ...


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 "...


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, ...


2

I would simply execute grep -He '\\<Sin\\>' *.nb in a command shell (with the appropriate working directory). You might be able to do this within Mathematica, but I doubt it would be worth the trouble.


1

While SelectionMove[EvaluationNotebook[], All, Notebook] returns $Failed you can use: NotebookDelete @ Cells[]


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"]}]


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 ...


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 ...



Only top voted, non community-wiki answers of a minimum length are eligible