# Why doesn't my package load and execute? [duplicate]

This might be a stupid question but I simply don't get my head around this. I'm trying to define variables and functions in different files (tried everything: nb, m, ...) and include them for use in a NoteBook (or whatever would work).

Mathematica seems to overcomplicate everything. I simply want to include code which is written in one file into another! Can't be that hard... But obviously I did not understand the very concept of using this properly.

Here's what I have so far:

This is my config.m

BeginPackage["config"];

BranchName::usage = "Returns Branch Name";
BranchInfo::usage = "Retruns Branch Info";
PrimaryVariables::usage = "use";

Begin["Private"];
BranchName = "TAPIR 1D - Atmospheric Accretion around Planets";
BranchInfo =
"Dynamical accretion of primordial atmospheres around planets.";
PrimaryVariables = {
{1, R, "MR", "Grid Equation"},
{2, m, "MM", "Poisson Equation"},
{3, rho, "MD", "Continuity Equation"},
{4, rhoAv, "MDa", "Continuity Equation (averaged density)"},
{5, e, "ME", "Energy Equation (internal gas energy density)"},
{6, u, "MU", "Equation of Motion"},
{7, J, "MJ", "Equation of Radiation-Flux Energy Density"},
{8, H, "MH", "Equation of Radiation-Flux"},
{9, uT, "MT", "Equation of Turbulent Convection"}
};

(* Protect Config Variables *)
\
(*Protect[BranchName,BranchInfo,PrimaryVariables];
Protect[R,m,rho,rhoAv,e,u,J,H,uT];*)
End[];

EndPackage[];


This then should be called from my notebook: test.nb

<< config.m;

BranchName


What is it what I don't understand?

Thanks!

Update ---

Sorry totally forgot to add the output. This is it:

In[1]:=BranchName
Out[1]=BranchName
`

## marked as duplicate by m_goldberg, José Antonio Díaz Navas, Kuba♦Mar 3 '18 at 5:45

• We can't read your mind, so maybe you should tell us what went wrong instead of asking us to tell you what you don't understand? There are many examples of this kind of thing online; here's one example you could look at (github.com/noahbenson/Neurotica), specifically the Installation section of the main README/page. – nben Mar 2 '18 at 16:16
• Hi! Thank's for the link but unfortunately this is not what I was looking for. It does not really explain how to use packages. – Florian Ragossnig Mar 2 '18 at 16:30
• Did you make all the code input cells in your package file initialization cells before you saved it? – m_goldberg Mar 2 '18 at 16:32
• I guess not. How do I do that? When I go to Cell->Convert To I only have the options: InputForm, Raw InputForm, OutputForm, StandardForm, TraditionalForm, Bitmap – Florian Ragossnig Mar 2 '18 at 16:36
• I do see it in the Notebook as I used the variable in order to show me the content. Like if I define a=1 and evaluate, i will get 1 as an output – Florian Ragossnig Mar 2 '18 at 16:47