Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1998

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

Search the Archive

Re: nice Gotcha!

  • To: mathgroup at
  • Subject: [mg15069] Re: nice Gotcha!
  • From: "Allan Hayes" <hay at>
  • Date: Thu, 10 Dec 1998 03:13:02 -0500
  • References: <74aiui$>
  • Sender: owner-wri-mathgroup at

Two suggetions

1) use Block instead of Module

test[] := Block[{x}, ToExpression["x=3"]; Print[x];] test[]




2) Since you seem to want a print response, stay with strings: using

StringReplace["x=3", "x=" -> ""]


or if you need to evaluate

a = 3;
Print[ToExpression[StringReplace["x=a", "x=" -> ""]]]


Barthelet, Luc wrote in message <74aiui$45l at>...
>Code similar to the following gave me trouble today. I thought it would
>be fun to share:
>test[] := Module[
>      {x},
>      ToExpression["x=3"];
>      Print[x];
>      ];
>In my version. "x" was infact the variable "Active" which is an option
>to ButtonBox and created a ton of problems. Of course I could not
>change the name (user driven, and that's why I am running a
>ToExpression on it).
>The solution was to not declare Active in the Module and to
>Clear[Active] in the function.
>any other insight?
>Luc Barthelet
>GM the day, Mayor at night

  • Prev by Date: help!!
  • Next by Date: Re: TableHeadings
  • Previous by thread: Re: nice Gotcha!
  • Next by thread: Question on Nest[]