Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1992

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

Search the Archive

Re: External commands into history buffer

  • To: mathgroup at
  • Subject: Re: External commands into history buffer
  • From: twj
  • Date: Thu, 19 Nov 92 10:20:53 CST

>As far as I am concerned I would prefer to have all the commands
>read in from the external file included in the internal history buffer.
>This would allow an easy reference to or editing of the read in commads
>without a proliferation of fractions of original command file if one
>does not want to edit and run it as a whole again and again. I did not
>have a look into this yet but if somebody did I would appreciate any
>suggestions, comments, etc.

Remember that the history "buffer" is just a collection of Mathematica
expressions.   You can alter it with whatever Mathematica commands you
wish.  For example you can make a version of Get which will update
In and Out:

GetHistory[ file_String] :=
        Block[{ coms, first},
                coms = ReadList[ file, Hold[ Expression]] ;
                first = $Line ;
                Unprotect[ In, Out] ;
                coms = Last[ Map[ GetHistoryAux, coms]] ;
                Out[ first] = coms ;
                Protect[ In, Out] ;

GetHistoryAux[ com_] :=
                $Line++ ;
                com /. Hold[ x_] :> SetDelayed[ In[ $Line], x] ;
                res = ReleaseHold[ com] ;
                Set[ Out[ $Line], res] ;

In[7]:= !!test1   

+ 5

Integrate[ f[x], {x,

In[7]:= GetHistory[ "test1"]

Out[9]= Integrate[f[x], {x, 0, Infinity}]

In[10]:= %%  

Out[10]= 6

Tom Wickham-Jones

  • Prev by Date: ListPlot3D
  • Next by Date: Integrate[z (1-z^2)^(-1/4),{z,-1,1}]
  • Previous by thread: External commands into history buffer
  • Next by thread: InputString bug, NeXT