Re: How to make dynamic strings?
- To: mathgroup at smc.vnet.net
- Subject: [mg111930] Re: How to make dynamic strings?
- From: David Bailey <dave at removedbailey.co.uk>
- Date: Thu, 19 Aug 2010 07:22:04 -0400 (EDT)
- References: <firstname.lastname@example.org>
On 18/08/10 12:04, sam ti83 wrote: > Hi, > > I'd like to make a string from a dynamic expression. I don't know how to do that since mathematica doesn't recognize the regular way of making strings from normal expressions (see below) - and I can't find any documentation on this problem. So your help is very welcome! > > This is a very simple example to illustrate my problem: > > In:= par1 = 200; > par2 = Dynamic[par1]; > par3 = ToString[par2] > > Out= "Dynamic[par1]" > > Instead of having par3 = "200", I get par3= "Dynamic[par1]". Do you know why mathematica doesn't evaluate a dynamic expression in ToString? Any solutions?? > > Thanks, > Sam > > > Dynamic just wraps an expression, and does nothing unless sent to the frontend. You need to remove this: ToString[par2/.Dynamic->Identity] Note that this method caters for slightly more complex situations in that Dynamic has become embedded further in an expression. However, in general you should not get into the situation! You really only want to use Dynamic in expressions that are being sent to the frontend. Dynamic does nothing useful in any other context and perhaps it should have been called FrontEndDynamic or some such, to make this clearer. David Bailey http://www.dbaileyconsultancy.co.uk