(* Content-type: application/vnd.wolfram.mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 13.1' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 158, 7] NotebookDataLength[ 255765, 5753] NotebookOptionsPosition[ 99290, 2790] NotebookOutlinePosition[ 241356, 5457] CellTagsIndexPosition[ 239547, 5407] WindowTitle->CellEvaluationButton | Definition Notebook WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["CellEvaluationButton", "Title", CellTags->{"Name", "TemplateCell", "Title"}, CellID->160760633], Cell["Make a button that evaluates a set of cells when clicked", "Text", CellTags->{"Description", "TemplateCell"}, CellID->737485164], Cell[CellGroupData[{ Cell[TextData[{ "Definition", Cell[BoxData[ PaneSelectorBox[{True-> TemplateBox[{"Function", Cell[ BoxData[ FrameBox[ Cell[ "Define your function using the name you gave in the Title line \ above. You can add input cells and extra code to define additional input \ cases or prerequisites. All definitions, including dependencies, will be \ included in the generated resource function.\n\nThis section should be \ evaluated before creating the Examples section below.", "MoreInfoText"], Background -> GrayLevel[0.95], FrameMargins -> 20, FrameStyle -> GrayLevel[0.9], RoundingRadius -> 5, ImageSize -> { Scaled[0.65], Automatic}]], "MoreInfoText", Deletable -> True, CellTags -> {"SectionMoreInfoFunction"}, CellMargins -> {{66, 66}, {15, 15}}]}, "MoreInfoOpenerButtonTemplate"]}, Dynamic[ CurrentValue[ EvaluationNotebook[], {TaggingRules, "ResourceCreateNotebook"}]], ImageSize->Automatic]]] }], "Section", Editable->False, Deletable->False, TaggingRules->{"TemplateGroupName" -> "Function"}, DefaultNewCellStyle->"Input", CellTags->{"Definition", "Function", "TemplateCellGroup"}, CellID->72845326], Cell[CellGroupData[{ Cell["Options", "Subsection", CellChangeTimes->{{3.778437103188347*^9, 3.778437103891617*^9}}, CellLabel->"In[23]:=", CellID->155172006], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"Options", "[", "CellEvaluationButton", "]"}], "=", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"Join", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"FilterRules", "[", RowBox[{ RowBox[{"Options", "[", "Button", "]"}], ",", RowBox[{"Except", "@", "#"}]}], "]"}], ",", "\[IndentingNewLine]", "#"}], "\[IndentingNewLine]", "]"}], "&"}], ")"}], "@", RowBox[{"{", "\[IndentingNewLine]", RowBox[{ RowBox[{"Method", "\[Rule]", "\"\\""}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"AutoScroll", "\[Rule]", "False"}], ",", "\[IndentingNewLine]", RowBox[{"\"\\"", "\[Rule]", "None"}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", " ", "undocumented", " ", "*)"}], "\[IndentingNewLine]", RowBox[{"\"\\"", "\[RuleDelayed]", RowBox[{"CreateUUID", "[", "\"\\"", "]"}]}]}], "\[IndentingNewLine]", "}"}]}]}], ";"}]], "Input", CellChangeTimes->{{3.7784234957034883`*^9, 3.7784235064715853`*^9}, 3.778423573647913*^9, {3.7784340375431767`*^9, 3.778434067328644*^9}, { 3.77843436557902*^9, 3.7784343700509453`*^9}, 3.778434602931871*^9, 3.778435873930634*^9, {3.7784359979833803`*^9, 3.778436073731167*^9}, { 3.778440164893436*^9, 3.778440233226759*^9}, 3.778443710089857*^9}, CellLabel->"In[1]:=", CellID->8597272] }, Open ]], Cell[CellGroupData[{ Cell["Explicit list of cells", "Subsection", CellChangeTimes->{{3.778423703886704*^9, 3.778423722259589*^9}, { 3.778435985550968*^9, 3.77843598703967*^9}}, CellLabel->"In[2]:=", CellID->927475443], Cell[BoxData[ RowBox[{ RowBox[{"CellEvaluationButton", "[", RowBox[{ RowBox[{"label_", ":", "\"\\""}], ",", RowBox[{"cells", ":", RowBox[{"{", "CellObject__", "}"}]}], ",", RowBox[{"opts", ":", RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "\[IndentingNewLine]", RowBox[{ RowBox[{"nb", "=", RowBox[{"EvaluationNotebook", "[", "]"}]}], ",", "\[IndentingNewLine]", RowBox[{"buttonUUID", "=", RowBox[{"OptionValue", "[", "\"\\"", "]"}]}], ",", "\[IndentingNewLine]", RowBox[{"confirmationText", "=", RowBox[{ RowBox[{"OptionValue", "[", "\"\\"", "]"}], "/.", RowBox[{ RowBox[{"(", RowBox[{"Automatic", "|", "True"}], ")"}], "\[Rule]", "\"\\""}]}]}], ",", "\[IndentingNewLine]", "doConfirmation", ",", "\[IndentingNewLine]", "targetedCells"}], "\[IndentingNewLine]", "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"doConfirmation", "=", RowBox[{"StringQ", "@", "confirmationText"}]}], ";", "\[IndentingNewLine]", RowBox[{"targetedCells", "=", RowBox[{"Select", "[", RowBox[{"cells", ",", RowBox[{ RowBox[{ RowBox[{"ParentNotebook", "[", "#", "]"}], "===", "nb"}], "&"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Length", "@", "targetedCells"}], "<", "1"}], ",", RowBox[{"Return", "[", RowBox[{"Failure", "[", RowBox[{"\"\\"", ",", RowBox[{"<|", RowBox[{ "\"\\"", "\[RuleDelayed]", "\"\\ \""}], "|>"}]}], "]"}], "]"}]}], "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"Scan", "[", RowBox[{ RowBox[{ RowBox[{"SetOptions", "[", RowBox[{"#", ",", RowBox[{"CellTags", "\[Rule]", RowBox[{"Append", "[", RowBox[{ RowBox[{"Flatten", "@", RowBox[{"{", RowBox[{"CurrentValue", "[", RowBox[{"#", ",", "CellTags"}], "]"}], "}"}]}], ",", "buttonUUID"}], "]"}]}]}], "]"}], "&"}], ",", "targetedCells"}], "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"With", "[", RowBox[{ RowBox[{"{", "\[IndentingNewLine]", RowBox[{ RowBox[{"$buttonUUID", "=", "buttonUUID"}], ",", "\[IndentingNewLine]", RowBox[{"$doConfirmation", "=", RowBox[{"TrueQ", "@", "doConfirmation"}]}], ",", "\[IndentingNewLine]", RowBox[{"$confirmationText", "=", "confirmationText"}], ",", "\[IndentingNewLine]", RowBox[{"$autoScroll", "=", RowBox[{"OptionValue", "[", "AutoScroll", "]"}]}]}], "\[IndentingNewLine]", "}"}], ",", "\[IndentingNewLine]", RowBox[{"Button", "[", "\[IndentingNewLine]", RowBox[{"label", ",", "\[IndentingNewLine]", RowBox[{"If", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"If", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"TrueQ", "@", "$doConfirmation"}], ",", RowBox[{"TrueQ", "@", RowBox[{"ChoiceDialog", "[", RowBox[{"$confirmationText", ",", RowBox[{"{", RowBox[{ RowBox[{"\"\\"", "\[Rule]", "True"}], ",", RowBox[{"\"\\"", "\[Rule]", "False"}]}], "}"}]}], "]"}]}], ",", "\[IndentingNewLine]", "True"}], "\[IndentingNewLine]", "]"}], ",", "\[IndentingNewLine]", RowBox[{"(", "\[IndentingNewLine]", RowBox[{ RowBox[{"NotebookFind", "[", RowBox[{ RowBox[{"ButtonNotebook", "[", "]"}], ",", "$buttonUUID", ",", "All", ",", "CellTags", ",", RowBox[{"AutoScroll", "\[Rule]", "$autoScroll"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"SelectionEvaluate", "[", RowBox[{"ButtonNotebook", "[", "]"}], "]"}], ";"}], "\[IndentingNewLine]", ")"}]}], "\[IndentingNewLine]", "]"}], ",", "\[IndentingNewLine]", RowBox[{"Sequence", "@@", RowBox[{"(", RowBox[{ RowBox[{ RowBox[{"#", "\[Rule]", RowBox[{"OptionValue", "[", "#", "]"}]}], "&"}], "/@", RowBox[{ RowBox[{"Options", "[", "Button", "]"}], "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}]}], ")"}]}]}], "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", "]"}]}]}], "\[IndentingNewLine]", "]"}]}]], "Input", CellChangeTimes->{{3.77842361228826*^9, 3.7784236574446783`*^9}, { 3.778423733008287*^9, 3.778423804535502*^9}, {3.778434184512398*^9, 3.7784341970190353`*^9}, {3.7784342447724047`*^9, 3.778434384998302*^9}, 3.778434604555538*^9, {3.778434685676304*^9, 3.778434689034638*^9}, { 3.7784347770181427`*^9, 3.7784347836980124`*^9}, 3.77843542652395*^9, 3.778436107618268*^9, {3.778436846549877*^9, 3.778436990765963*^9}, { 3.77844024535966*^9, 3.7784402495455647`*^9}, {3.7784432491233807`*^9, 3.778443278314168*^9}, 3.778443648900175*^9, {3.778443747189962*^9, 3.7784437839037333`*^9}}, CellLabel->"In[1]:=", CellID->249310393], Cell[CellGroupData[{ Cell["Single cell", "Subsubsection", CellChangeTimes->{{3.7784370814454193`*^9, 3.77843708651611*^9}}, CellLabel->"In[2]:=", CellID->855253571], Cell[BoxData[ RowBox[{ RowBox[{"CellEvaluationButton", "[", RowBox[{ RowBox[{"label_", ":", "\"\\""}], ",", "cell_CellObject", ",", RowBox[{"opts", ":", RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], ":=", RowBox[{"CellEvaluationButton", "[", RowBox[{"label", ",", RowBox[{"{", "cell", "}"}], ",", "opts"}], "]"}]}]], "Input", CellChangeTimes->{{3.7784365543953333`*^9, 3.778436567659768*^9}}, CellLabel->"In[1]:=", CellID->892424161] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Cell selection prompt", "Subsection", CellChangeTimes->{{3.778423717053254*^9, 3.778423720333475*^9}}, CellLabel->"In[2]:=", CellID->661746430], Cell[BoxData[ RowBox[{ RowBox[{"CellEvaluationButton", "[", RowBox[{ RowBox[{"label", ":", RowBox[{"Except", "[", RowBox[{"_", "?", "OptionQ"}], "]"}], ":", "\"\\""}], ",", RowBox[{"opts", ":", RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], ":=", RowBox[{"Module", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"{", "\[IndentingNewLine]", RowBox[{ RowBox[{"nb", "=", RowBox[{"EvaluationNotebook", "[", "]"}]}], ",", "\[IndentingNewLine]", "selectedCells"}], "\[IndentingNewLine]", "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"If", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"!", RowBox[{"TrueQ", "@", RowBox[{"ChoiceDialog", "[", RowBox[{ "\"\