MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Copy as InputForm

  • To: mathgroup at smc.vnet.net
  • Subject: [mg45171] Copy as InputForm
  • From: drbob at bigfoot.com (Bobby R. Treat)
  • Date: Fri, 19 Dec 2003 06:57:38 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Some of you already know this, but here's a nice way to clean up
Mathematica code and output before pasting it into e-mail (or other
text programs). Omega Consulting wrote the palette involved, which
performs "copy as InputForm".

Note to Wolfram: THIS SHOULD BE BUILT IN TO THE MATHEMATICA MENUS!

I put the palette in

C:\Documents and Settings\All Users\Application
Data\Mathematica\Applications\InputForm\FrontEnd\Palettes

Step 1) Create that directory (you can use a different name for the
InputForm directory if you want, or use a directory that already
exists in that position, like Utilities).
Step 2) Select the code below (all of it, and nothing else).
Step 3) Copy it.
Step 4) Paste it into Mathematica.
Step 5) Answer yes when Mathematica asks if you want to convert the
expression.
(Then you should see a new, untitled palette on your screen.)
Step 6) Close Mathematica, and it should ask if you want to save the
untitled palette. Save it in the above directory, name it whatever you
want. I named mine InputForm, so it became InputForm.nb.
Step 7) Reopen Mathematica.
Step 8) File>Palettes should show the new palette, and you're in
bidness.

I leave the palette always open. Select anything you want to copy into
a text program, push the palette button, and paste where you want it.

If the button turns out bigger than you like, reduce the number after
"Magnification->" near the bottom of the code.

Bobby 
code follows...

Notebook[{
Cell[BoxData[
    ButtonBox[
      RowBox[{
        RowBox[{"Copy", " ", "As"}], "\n", " ", "InputForm"}],
      ButtonFunction:>Module[ {cpy, cpynb, evalnb}, 
          CompoundExpression[ 
            Set[ cpy, 
              NotebookRead[ 
                InputNotebook[ ]]], 
            If[ 
              SameQ[ cpy, {}], 
              Return[ ]], 
            Set[ cpynb, 
              NotebookCreate[ Visible -> False]], 
            NotebookWrite[ cpynb, cpy], 
            SelectionMove[ cpynb, All, Notebook], 
            FrontEndExecute[ {
              FrontEndToken[ cpynb, "SelectionConvert",
"InputForm"]}],
            Set[ evalnb, 
              NotebookPut[ 
                Notebook[ 
                  Map[ Cell[ #, "Input"]&, {
                    BoxData[ 
                      RowBox[ {"cpynb", "=", 
                        ToBoxes[ cpynb]}]], 
                    "FrontEndExecute[{FrontEndToken[cpynb,            
       \
        \"CopySpecial\",\"PlainText\"]}]", "NotebookClose[cpynb]", 
                    "NotebookClose[EvaluationNotebook[]]"}], Visible
->
                  False]]], 
            SelectionMove[ evalnb, All, Notebook], 
            SelectionEvaluate[ evalnb], Null]],
      ButtonEvaluator->Automatic,
      Active->True]], NotebookDefault,
  CellMargins->{{Inherited, Inherited}, {7, Inherited}},
  PageBreakAbove->True,
  CellLabelMargins->{{12, Inherited}, {Inherited, Inherited}},
  InputAutoReplacements->{
    "->"->"\[Rule]", ":>"->"\[RuleDelayed]", "<="->"\[LessEqual]", 
      ">="->"\[GreaterEqual]", "!="->"\[NotEqual]", "=="->"\[Equal]", 
      Inherited},
  "TwoByteSyntaxCharacterAutoReplacement"->True,
  Hyphenation->True,
  LineSpacing->{1.25, 0},
  ScriptMinSize->9,
  CounterIncrements->"Text",
  StyleMenuListing->None,
  FontFamily->"Courier"]
},
FrontEndVersion->"5.0 for Microsoft Windows",
ScreenRectangle->{{0, 1280}, {0, 967}},
ClosingAutoSave->True,
Editable->False,
WindowToolbars->{},
PageWidth->334,
WindowSize->{116, 56},
WindowMargins->{{Automatic, 5}, {72, Automatic}},
WindowFrame->"Palette",
WindowElements->{},
WindowFrameElements->"CloseBox",
WindowClickSelect->False,
ScrollingOptions->{"PagewiseScrolling"->True,
"VerticalScrollRange"->Fit},
ShowCellBracket->False,
CellMargins->{{0, 0}, {Inherited, 0}},
Active->True,
CellOpen->True,
ShowCellLabel->False,
ShowCellTags->False,
ImageMargins->{{0, Inherited}, {Inherited, 0}},
Magnification->1.5
]


  • Prev by Date: Re: Get theoretical answer on linear equations
  • Next by Date: Re: Get theoretical answer on linear equations
  • Previous by thread: Re: NDSolve: avoiding negative values?
  • Next by thread: Copy as InputForm