Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1992
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*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

External commands into history buffer

  • To: mathgroup at yoda.physics.unc.edu
  • Subject: External commands into history buffer
  • From: Jan Lac Office C115 <janlac at paramount.nikhefk.nikhef.nl>
  • Date: Wed, 18 Nov 92 11:21:10 +0100

Dear MathGroup,

I think the following problem is worth of discussing:

> To: mathgroup at yoda.physics.unc.edu
> Subject: Plotting problems

> I have written an Mma program whose last 3 lines are:

> ListPlot[nodePairs,PlotJoined->True,DisplayFunction->Identity]
> Plot[S[x],{x,node[[1]],node[[n+1]]},DisplayFunction->Identity]
> Show[%,%%,DisplayFunction :> $DisplayFunction]

> When the program is executed the Show function will sometimes(rarely)  
> properly overlay the two previous plots but more often, one of the  
> following error messages are displayed with no graph:

> Show::gtype: String is not a type of graphics.
> Show::gtype: Show is not a type of graphics.

> However when the same 3 lines are executed in the notebook after the  
> program has bees run, the Show function produces the proper plot.

> Does anyone know what is wrong here?  Why are the error messages  
> inconsistent?

The substitution commands '%', '%%', etc. refer to the actual previous lines
as stored in the history log of the current session. That means if you read in
a program then no matter how many lines it contains the line counter system
variable $Line is incremented by one and only the command <<programname
is appended to the internal history log buffer.

Try this: In[k] Plot[Sin[x],{x,-Pi,Pi}, DisplayFunction->Identity]
          In[k+1] Plot[Cos[x],{x,-Pi,Pi}, DisplayFunction->Identity]
	  In[k+2] <<yourprogramname

Remember you have to type this commads in manually!

The solution to your problem:
Modify your file in the following way:

tmp1 =  ListPlot[nodePairs,PlotJoined->True,DisplayFunction->Identity]
tmp2 =  Plot[S[x],{x,node[[1]],node[[n+1]]},DisplayFunction->Identity]
Show[tmp2,tmp1,DisplayFunction :> $DisplayFunction]

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.

Greetings,

Jan Lac

P.S. Because I am not working with notebooks and wanted to have a look
into the history buffer of the current session I made the following
script which is very handy to have in init.m file. You might find it
usefull too when not working with notebooks:

     history[x_,y_] := Do[Print[i,"*> ",InString[i]],{i,x,y}]

------------------------------------------------------------------------------
>>  Jan Lac, NIKHEF-K, Postbus 41882, NL-1009 DB Amsterdam, The Netherlands <<
>>           e-mail: janlac at nikhef.nl    Fax: (31) 20 - 592 2165            <<
------------------------------------------------------------------------------







  • Prev by Date: Re: Plotting problems
  • Next by Date: InputString bug, NeXT
  • Previous by thread: Re: HypergeometricPFQ
  • Next by thread: Re: External commands into history buffer