Currently I am working on creating the package on Mathematica version 9 on Windows 7. Here is my code as follows:
BeginPackage["mypackage`"]
Begin["`Private`"]
getColumn[data_,branch_List]:=
Module[{pos},
pos = Position[data,#][[1,2]]&/@branch;
data[[All,pos]]
];
RemoveMissing[data_]:=DeleteCases[data,{date_,val_}/;!NumberQ[val]];
End[]
EndPackage[]
As you can see from the above that it contains two defined functions. I saved it as mypackage.m on my working directory.
To make sure my working directory is the one that contains mypackage.m, I put SetDirectory[NotebookDirectory[]]
in my notebook.
Then, I call the package by using
Needs["mypackage`"]
Evaluating, but it seems not to load, because when I call the function getColumn
, the letters should turn black if it is loaded (now it's still blue). Also, I tried other ways
`Needs["mypackage`","mypackage.m"]`
and
<<mypackage`
Both are still not working.
I have two questions:
When we save .m file, is it necessary to have the same name as we defined in the BeginPackage[""]
Is there anything missing so my package does not work ? any suggestions ?