Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm not really sure if this is a wise thing to do, but anyway. </p> <p>Here is a schematic solution for two Notebooks. It may be generalized, but it's not straightforward. </p> <ol> <li><p>Open two Notebooks</p></li> <li><p>In each of them go to the menu (evaluation -> Notebook's default context -> Unique to this Notebook) With this, the symbols are not shared anymore.</p></li> <li><p>In each Notebook enter something like <code>Context[]</code> to get the Notebook Context</p></li> <li><p>Now in each Notebook enter the following code </p></li> </ol> <p>. </p> <pre><code> Needs["Experimental`"]; SetAttributes[f, HoldFirst]; f[s_, val_] := ToExpression@StringJoin["Notebook$$17$799580`", ToString@Unevaluated@s, "=", ToString@val]; ValueFunction[t] = f </code></pre> <p>Where the <code>Notebook$$17$799580</code> is the context of THE OTHER Notebook (this should be able to be obtained "automatically", but this is a proof of concept only. </p> <p>Now when you want to share a symbol enter </p> <pre><code> f[symbolToShare] </code></pre> <p>That's it. </p> <p>You may share the value bidirectionally, or just in one direction, entering f[x] only in the Notebook you want as source value for x. The other Notebook will get the updated value, but it'll not update it back. </p> <p>HTH!</p> <p><b>Edit</b> </p> <p>Towards automation: </p> <p>You may get all other open Notebook Contexts to update your shared symbols as: </p> <pre><code>ctxs[]:= Complement[Contexts["Notebook$$*"], Flatten@Union[{Context[]}, StringCases[Contexts["Notebook$$*"], __ ~~ "Private" ~~ __]]] </code></pre> <p>So your f will become something like this (not tested)</p> <pre><code> f[s_, val_] := ToExpression@StringJoin[#, ToString@Unevaluated@s, "=", ToString@val]&amp;/@ctxs[]; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload