Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • $\begingroup$ Actually I don't underand exactly what's going on here, and I doubt that it is doing what probably was intended, although I of course don't know what the intend was and whether this situation was considered at all. On the other hand I think your code has other problems: is it intended that the frontend variable obj will be replaced with an new "instance" of the module variable obj$xxx at every button press? Use get[obj] ^:= {obj, Hold[u], u, Date[]}; to see what I mean. $\endgroup$ Commented Jan 25, 2012 at 21:36
  • 1
    $\begingroup$ Changing SetDelayed to Set in the initialization part fixes this issue. It seems that with SetDelayed the first run is just defining makeObject[] without executing it. $\endgroup$ Commented Jan 25, 2012 at 22:40
  • $\begingroup$ @kguler this solution doesn't work though if you want makeObject to have arguments. $\endgroup$ Commented Jan 25, 2012 at 23:16
  • $\begingroup$ @Faysal, you are right. $\endgroup$ Commented Jan 25, 2012 at 23:34
  • $\begingroup$ @Nasser nice comparison, so method 3 is the best, and it keeps the code in the Initialization part, good to know. $\endgroup$ Commented Jan 26, 2012 at 8:17