Re: creating input cell with unevaluated expression?
- To: mathgroup at smc.vnet.net
- Subject: [mg20147] Re: [mg20089] creating input cell with unevaluated expression?
- From: "Carl K.Woll" <carlw at fermi.phys.washington.edu>
- Date: Sat, 2 Oct 1999 03:05:06 -0400
- Organization: Department of Physics
- References: <199909300643.CAA02205@smc.vnet.net.>
- Sender: owner-wri-mathgroup at wolfram.com
Aaron, In Mathematica 4.0, your second idea works perfectly, StylePrint[Unevaluated[1+1],"Input"] In Mathematica 3.0, it doesn't. I Traced the above function, and came up with a potential workaround, which is to give StylePrint the attribute HoldAllComplete. This may not be a very wise thing to do, however, so caveat emptor I guess. Anyway, first execute SetAttributes[StylePrint, HoldAllComplete] and then try out your second idea. Carl Woll Physics Dept U of Washington Aaron Gross wrote: > Can anyone tell me how to do the following? I want to write an > expression that creates and inserts (at the current position in the > front-end) an input cell containing a given *unevaluated* expression, > just as if the user had typed it in himself. For instance, I'd like > to create an input cell containing the expression "1+1", so that if > the user then evaluates the cell, he gets an output cell containing > "2". > > I tried > > StylePrint[HoldForm[1+1],"Input"] > > but that doesn't work -- the input cell still has the "Hold" tag, so > when the user evaluates it by hand, he gets an output cell containing > "1+1" rather than "2". > > I also tried > > StylePrint[Unevaluated[1+1],"Input"] > > but that just gave me a "2" in the input cell. So what's the "right" > way to do this?