Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

In the system resource file MiscStrings.tr there is a template:

@@resource PackageTemplate
Notebook[{
Cell[BoxData[
    RowBox[{"BeginPackage", "[", "\"\<\[Placeholder]`\>\"", "]"}]], "Code"],
Cell[BoxData[
    RowBox[{"Begin", "[", "\"\<`Private`\>\"", "]"}]], "Code"],
Cell[BoxData[
    RowBox[{"End", "[", "]"}]], "Code"],
Cell[BoxData[
    RowBox[{"EndPackage", "[", "]"}]], "Code"]
}]

I suppose there is also an automatic way to insert or use this template. What is it?

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

You can get the template using FrontEndResource:

 FrontEndResource["PackageTemplate"]
 (* Notebook[
  {Cell[BoxData[RowBox[{"BeginPackage", "[", "\"\[Placeholder]`\"", "]"}]], "Code"], 
   Cell[BoxData[RowBox[{"Begin", "[", "\"`Private`\"", "]"}]], "Code"],
   Cell[BoxData[RowBox[{"End", "[", "]"}]], "Code"], 
   Cell[BoxData[RowBox[{"EndPackage", "[", "]"}]], "Code"]}] *)

Usage example:

NotebookPut[FrontEndResource["PackageTemplate"]]

enter image description here

share|improve this answer
    
I thought I must be missing something; thanks. Is FrontEndResource documented somewhere? –  Mr.Wizard Aug 13 '12 at 14:08
2  
@Mr.Wizard, I have not come across anything in the docs; but, as you must have noticed, text resource files have several example uses such as the piece FrontEndExecute[FrontEnd`NotebookPut[FEPrivate`FrontEndResource["FEExpressions"‌​, "SlideshowTemplate"]]] in MenuSetup.tr. Finding the right syntax took several "trial-and-crash" attempts. –  kguler Aug 13 '12 at 14:35
    
@Mr.Wizard This is not your first encounter with FrontEndResource. See your answer here. –  Sjoerd C. de Vries Aug 13 '12 at 19:59
    
@Sjoerd More evidence of my failing memory. ::sigh:: –  Mr.Wizard Aug 14 '12 at 0:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.