MathGroup Archive 2010

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

Search the Archive

DynamicModule not saving reliably a variable between sessions

  • To: mathgroup at
  • Subject: [mg106797] DynamicModule not saving reliably a variable between sessions
  • From: Hannes Kessler <HannesKessler at>
  • Date: Sat, 23 Jan 2010 07:37:03 -0500 (EST)


I have a rather complex dynamic notebook GUI with several TabView,
Button, InputField and other objects that does not save reliably a
variable "jobs" between Mathematica sessions. The basic structure of
the GUI is a follows:

DynamicModule[{jobs = {}, ...},
 TabView[{..., "Edit jobs" -> Dynamic[jobDefinitionPanel
[jobs_, ...]], ...}],
 Initialization :> AbortProtect[

where jobDefinitionPanel has the attribute HoldAll and contains a
button for adding an object Job["name"->...,"item 1"->..., "item 2"-
>..., ...] to the list of jobs

jobDefinitionPanel[jobs_, ...] := DynamicModule[{..},
      Button["Add job", jobs = Append[jobs, makeJob[ ...]], Method ->

makeJob[ ...] returns _Job objects of the form given above:

makeJob[name_String, item1_, item2_, ...] :=
 Job["name" -> name, "item 1" -> item1, "item 2" -> item2, ...]

In a given Mathematica session everything works fine: After adding
several job objects, Dynamic[Length[jobs]] shows the correct length of
the jobs list. Exporting the list with CellPrint[Cell[BoxData[ToBoxes
[jobs]]]] from the GUI to its notebook shows the jobs list {__Jobs}
with all _Job elements. But saving, closing and reopening the notebook
always gives a shorter jobs list, sometimes it is even empty. The _Job
objects are rather large due to one item which is a 15x15 matrix of
elements None or FA[...]. The problem does not occur if I do not add
this item to Job-objects. It looks as if a size limitation exists for
saving dynamic objects in the notebook cell containing the dynamic

Does anybody have an idea what the reason might be and how to fix this

My current workaround is to additionally save the jobs list to a file

Button["Add job", jobs = savedJobs =..; Save["jobs.m", savedJobs],
 Method -> "Queued"]

and to load this file during initialization

DynamicModule[{jobs = {}, ...},
 Initialization :> AbortProtect[
    jobs = savedJobs;

Thanks in advance and best regards,

Hannes Kessler

  • Prev by Date: Re: Finding and changing strings in a matrix
  • Next by Date: Re: Finding and changing strings in a matrix
  • Previous by thread: Re: Creating new ColorFunction / ColorDataFunction
  • Next by thread: Re: DynamicModule not saving reliably a variable between