
Notebook

Ken
I am a little confused about preserving the contents of a notebook and reconstructing a notebook.
I have a button that performs the following upon activation:
Window NotesWin() NewNotebook/W=(574,603,773,699) /F=0/K=3 /N=Notes EndMacro
If I click the button and type "Test" into the notebook, and do:
string/G ActiveWindows = WinList("*",";","") Make/T/O/N=(ItemsinList(ActiveWindows,";")) Recreation = "" variable x for (x = 0; x < ItemsinList(ActiveWindows,";"); x += 1) Recreation[x] = WinRecreation(StringFromList(x,ActiveWindows,";"),4) endfor
Then kill all open windows, and run:
variable x, Count = numpnts(Recreation) wave/T Recreation for (x = 0; x < Count; x += 1) execute Recreation[x] endfor
Every window except for the notebook reappears in its original state. For the notebook, I either receive an error saying that the execute command string is too long (even though the recreation code for the notebook is actually shorter than the other recreation codes), or nothing happens. If I print the Recreation array element corresponding to the notebook, one of the lines says, "Notebook $nb ruler=Normal, text="Test"", so the contents are saved, just not displayed.
Can someone help me understand this?
Thank you.
BTW, I would make ActiveWindows local but making it global might be useful during debugging.
Next, if you read the Notebook Details section for WinRecreation, you will see that, for a notebook, it does not return a recreation macro as it does for graphs, tables, and layouts. Because it contains multiple lines but is not a recreation macro, Execute can't execute it.
Because notebooks can contain an indefinite amount of text, we store them in files and don't create recreation macros for notebooks.
Also note that the last parameter you are passing to WinRecreation depends on the type of the window. Therefore you will need some more logic based on the window type.
You might want to make your Recreation wave into a 2D text wave with the first column containing the type of the window, the second containing the window name, and the third containing the recreation text.
You might be able to achieve what you want by prepending "Macro SomeName()\r" and appending "\rEnd" to the text returned by WinRecreation for notebooks.
Here is a function that might give you an idea of how to achieve what you want:
This returns text that can be executed by Execute.
If this does not get you going, explain what you are attempting to do - there might be another approach.
November 12, 2011 at 04:56 pm - Permalink