Re: Need portable code to open Notation palette.
- To: mathgroup at smc.vnet.net
- Subject: [mg59359] Re: Need portable code to open Notation palette.
- From: albert <awnl at arcor.de>
- Date: Sun, 7 Aug 2005 03:46:54 -0400 (EDT)
- References: <dd1i7f$18n$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi Ted, > But I worry that this won't work for all users. I want to support all > versions of Mathematica from 3.0 to 5.2 and beyond. I also want it to work > under MS-Windows, UNIX, Linux, and Mac. How do I know the code above will > not work for some users? my first idea was that maybe the search algorithm for palettes in newer version would have changed and include the language directories now. Then it would probably have helped to include the ExtraPackages-Directory to the NotebookPath option of the FrontEnd. Obviously that ist not the case and there are some open questions why the NotebookPalette.nb ist put in the very directory it is in the various versions. It does not conform to the standards I see in the other packages. I also wonder whether the ExtraPackages-Directory should better be listed in the NotebookPath or PalettePath options of the FrontEnd or not, even though at this time none of the ExtraPackages seems to provide any Palettes or Notebooks, except for Notations`... > It would be nice if I could tell the kernel to find "NotationPalette.nb" > and return the list I need to give FrontEnd`FileName[ ]. How can this be > done? so the only thing you seem to be left with is to search for the file as you asked for. This could be done with: First[FileNames[ "NotationPalette.nb", ToFileName[{$TopDirectory, "AddOns", "ExtraPackages", "Utilities", "Palettes"}], Infinity ]] this will not return the list you are looking for but a string with the full path to the file. Anyway I think it should be ok on any platform and Mathematica version to pass this to NotebookOpen without constructing the list you were asking for. Since the Kernel is involved anyway it doesn't make sence to try to stick to FrontEnd-functionality anyway. To be on the save side you might want to check whether there is a match in the call to FileNames at all or wether there are more than one instead of blindly trying the first in the list: NotebookOpen[ First[FileNames["NotationPalette.nb", ToFileName[{$TopDirectory, "AddOns", "ExtraPackages", "Utilities"}], Infinity]]] This works for every combination of mathematica/OS I have access to ( Linux 4.0, Linux 5.1, Windows 4.2 and Windows 5.1) and I'm quite sure it will work on other combinations to, except maybe for 3.0, I never have used the frontend before version 4... One more thing: to be save about future versions you might need a switch between $TopDirectory and $InstallationDirectory, since $TopDirectory seems to be deprecated (at least is no longer documented) in version > 5 and $InstallationDirectory did not exist in versions < 4... Albert