MathGroup Archive 2005

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

Search the Archive

Re: Add new option to Notebook[]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg55294] Re: [mg55240] Add new option to Notebook[]
  • From: John Fultz <jfultz at wolfram.com>
  • Date: Fri, 18 Mar 2005 05:34:35 -0500 (EST)
  • Reply-to: jfultz at wolfram.com
  • Sender: owner-wri-mathgroup at wolfram.com

 On Thu, 17 Mar 2005 03:29:52 -0500 (EST), rod at flyingspinach.com wrote:
> Hi,
>
> I'd like to add a new option to Notebook[], so that I could write
> Notebook[{...}, NewOption->"new_option_string"].  Then I would be able
> to say Options[Notebook, NewOption] and get back the string
> "new_option_string".  Can this be done?
>
> I've tried Options[Notebook] = Append[NewOption, Options[Notebook]]
> with no success.
>
> Thanks,
>
> -Rod


You want to use SetOptions, and you want to use it on a specific notebook.  
Generally, I'd recommend storing your information away inside of the 
TaggingRules option, which is an option we've specifically designated for 
this kind of use.  I.e.,

SetOptions[InputNotebook[], TaggingRules->{NewOption->"new option string"}]

Although...a bit of arcane knowledge here...if you tried the SetOptions 
syntax directly on the option, it *would* work, but in some slightly 
unexpected way...

In[3]:= SetOptions[InputNotebook[],NewOption->"new option string"]

(* a beep happens *)

In[4]:= Options[InputNotebook[],NewOption]

 From In[4]:= Options::optnf: NewOption is not a known option for 
NotebookObject.

Out[4]= {}

In[5]:= Options[InputNotebook[]]

Out[5]= {FrontEndVersion->5.1 for Microsoft Windows,
  ScreenRectangle->{{0.,1600.},{0.,1117.}}, WindowSize->{495.,740.},
  WindowMargins->{{24.,Automatic},{Automatic,30.}},
  NewOption->new option string, StyleDefinitions->Default.nb}

So, what's going on here?  This is using a mechanism for forward 
compatibility...i.e. what if a notebook from a future version with unknown 
options were to be read by 5.1?  We don't want it to totally break...in 
fact, it should just preserve options it doesn't understand.  So, that's 
exactly what it's doing.  Options[] on that specific option won't work 
because, internally, the option has been squirreled away into a hidden 
option, but that hidden option always writes its contents out to files and 
the general Options[] requests.

								-John



  • Prev by Date: Re: Re: GridLines
  • Next by Date: Re: Re: J/Link problem on Mac OS X
  • Previous by thread: Re: Add new option to Notebook[]
  • Next by thread: Re: Add new option to Notebook[]