MathGroup Archive 2011

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

Search the Archive

Re: How to get last input line in MathLink mode?

  • To: mathgroup at
  • Subject: [mg116575] Re: How to get last input line in MathLink mode?
  • From: Alexey <lehin.p at>
  • Date: Sun, 20 Feb 2011 05:26:33 -0500 (EST)
  • References: <ijitrt$2r4$>

Here is the function I have developed for this:

In[1]:= getLastInput :=
 Module[{num, f},
  f = Function[{u, v}, {u /. {In -> num, HoldPattern -> First},
     HoldComplete[v]}, HoldAllComplete];
    Block[{RuleDelayed = f}, DownValues[In]], {$Line - 1, x_} ->
     x, {1}, 1]]

In[2]:= Evaluate[1 + 1]

Out[2]= 2

In[3]:= getLastInput

Out[3]= HoldComplete[Evaluate[1 + 1]]

The problem was that RuleDelayed partially evaluates its r.h.s. in
contradiction with the Documentation:

In[9]:= a:>Unevaluated[b] // FullForm
Out[9]//FullForm= RuleDelayed[a,b]

And I have got the answer to the question on InString in MathLink mode
from Todd Gayley (Wolfram Research):

> InString is only assigned when using EnterTextPacket, not
> EnterExpressionPacket. There is no string form of the input when
> sending EnterExpressionPacket (whose content is, by definition,
> already an expression).

  • Prev by Date: Re: Interpolation difficulty
  • Next by Date: Re: NDSolve Unable to find initial conditions that satisfy the
  • Previous by thread: How to get last input line in MathLink mode?
  • Next by thread: Unexpected behavior of Plot3D