|
[Date Index]
[Thread Index]
[Author Index]
Re: StringForm bug?
- To: mathgroup at smc.vnet.net
- Subject: [mg65488] Re: StringForm bug?
- From: David Bailey <dave at Remove_Thisdbailey.co.uk>
- Date: Wed, 5 Apr 2006 06:55:28 -0400 (EDT)
- References: <e0dp2k$q6p$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
pdickof at scf.sk.ca wrote:
> I create a form...
>
> myForm = " Line `1`\n
> Line `2`\n
> Line `3`"
>
> Executing the StringForm line below gives me what I expect and want...
>
> StringForm[myForm, 1, 2, 3]
>
> but if I try to create an ordinary String from the StringForm object...
>
> InputForm[ToString[StringForm[myForm, 1, 2, 3]]]
>
> ... I get...
>
> " Line 1 2 3\n Line Line "
>
> Which is apparently wrong and certainly not what I want. How do I get
> this to work?
> I am running Mathematica 5.2
>
> Thanks in advance.
> Peter Dickof
>
Hi,
I am not sure I would classify this as a bug, but if you look at the
help for StringForm, it says
"StringForm acts as a wrapper, which affects printing, but not evaluation."
This seems to be Wolfram-speak for "Useful as a wrapper for printing,
but nothing else!" These wrappers - such as MatrixForm - often get left
in expressions that are used elsewhere, and they cause a lot of mischief!
In this case, there is no reason to expect ToString to operate usufully
on your StringForm - and it doesn't!
I would use StringReplace to achieve what you want to do. The
replacements must be strings - but you can use ToString to achieve that.
David Bailey
http://www.dbaileyconsultancy.co.uk
Prev by Date:
graphic inside a gridbox
Next by Date:
Loop and Lost values - The Sequel
Previous by thread:
Re: graphic inside a gridbox
Next by thread:
Loop and Lost values - The Sequel
|