Skip to main content
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Source Link

The problem is that the first time Manipulate is executed makeObj[] is not yet defined when obj is initialized. But if you put the definition of makeObj[] just before calling it, it works !

See this related post that lead to this question How can you give a Module a context and have its local variables and Modules belong to that context?How can you give a Module a context and have its local variables and Modules belong to that context?. It contains many different ideas about representing simple objects in MM.

Manipulate[ x; init[obj]; get[obj] , Button["run", x++] , {x, None} , {{obj, makeObj[] := Module[{Obj, u}, init[Obj] ^:= u = {1, 2, 3}; get[Obj] ^:= {u, Date[]}; Obj ]; makeObj[]}, None} , TrackedSymbols :> {x} ] 

The problem is that the first time Manipulate is executed makeObj[] is not yet defined when obj is initialized. But if you put the definition of makeObj[] just before calling it, it works !

See this related post that lead to this question How can you give a Module a context and have its local variables and Modules belong to that context?. It contains many different ideas about representing simple objects in MM.

Manipulate[ x; init[obj]; get[obj] , Button["run", x++] , {x, None} , {{obj, makeObj[] := Module[{Obj, u}, init[Obj] ^:= u = {1, 2, 3}; get[Obj] ^:= {u, Date[]}; Obj ]; makeObj[]}, None} , TrackedSymbols :> {x} ] 

The problem is that the first time Manipulate is executed makeObj[] is not yet defined when obj is initialized. But if you put the definition of makeObj[] just before calling it, it works !

See this related post that lead to this question How can you give a Module a context and have its local variables and Modules belong to that context?. It contains many different ideas about representing simple objects in MM.

Manipulate[ x; init[obj]; get[obj] , Button["run", x++] , {x, None} , {{obj, makeObj[] := Module[{Obj, u}, init[Obj] ^:= u = {1, 2, 3}; get[Obj] ^:= {u, Date[]}; Obj ]; makeObj[]}, None} , TrackedSymbols :> {x} ] 
edited body
Source Link
faysou
  • 11.1k
  • 3
  • 52
  • 159

The problem is that the first time Manipulate is executed makeObj[] is not yet defined when obj is initialized. But if you put the definition of makeObj[] just before calling it, it works !

See this related post that lead to this question How can you give a Module a context and have its local variables and Modules belong to that context?. It contains many different ideas about representing simple objects in MM.

Manipulate[ x; init[obj]; get[obj] , Button["run", x++] , {x, None} , {{obj, makeObj[] := Module[{objObj, u}, init[obj]init[Obj] ^:= u = {1, 2, 3}; get[obj]get[Obj] ^:= {u, Date[]}; objObj ]; makeObj[]}, None} , TrackedSymbols :> {x} ] 

The problem is that the first time Manipulate is executed makeObj[] is not yet defined when obj is initialized. But if you put the definition of makeObj[] just before calling it, it works !

See this related post that lead to this question How can you give a Module a context and have its local variables and Modules belong to that context?. It contains many different ideas about representing simple objects in MM.

Manipulate[ x; init[obj]; get[obj] , Button["run", x++] , {x, None} , {{obj, makeObj[] := Module[{obj, u}, init[obj] ^:= u = {1, 2, 3}; get[obj] ^:= {u, Date[]}; obj ]; makeObj[]}, None} , TrackedSymbols :> {x} ] 

The problem is that the first time Manipulate is executed makeObj[] is not yet defined when obj is initialized. But if you put the definition of makeObj[] just before calling it, it works !

See this related post that lead to this question How can you give a Module a context and have its local variables and Modules belong to that context?. It contains many different ideas about representing simple objects in MM.

Manipulate[ x; init[obj]; get[obj] , Button["run", x++] , {x, None} , {{obj, makeObj[] := Module[{Obj, u}, init[Obj] ^:= u = {1, 2, 3}; get[Obj] ^:= {u, Date[]}; Obj ]; makeObj[]}, None} , TrackedSymbols :> {x} ] 
Source Link
faysou
  • 11.1k
  • 3
  • 52
  • 159

The problem is that the first time Manipulate is executed makeObj[] is not yet defined when obj is initialized. But if you put the definition of makeObj[] just before calling it, it works !

See this related post that lead to this question How can you give a Module a context and have its local variables and Modules belong to that context?. It contains many different ideas about representing simple objects in MM.

Manipulate[ x; init[obj]; get[obj] , Button["run", x++] , {x, None} , {{obj, makeObj[] := Module[{obj, u}, init[obj] ^:= u = {1, 2, 3}; get[obj] ^:= {u, Date[]}; obj ]; makeObj[]}, None} , TrackedSymbols :> {x} ]