# Avoid "Protected, Locked , Private package" warnings from this code?

**URL:** <https://community.wolfram.com/t/avoid-protected-locked-private-package-warnings-from-this-code/8829>\
**Category:** Questions\
**Tags:** software-development, mathematica, computable-document-format, packages-and-paclets\
**Created:** [July 2, 2016, 10:22am UTC](https://community.wolfram.com/t/avoid-protected-locked-private-package-warnings-from-this-code/8829 "2016-07-02T10:22:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![erdemuguz1](https://avatars.discourse-cdn.com/v4/letter/e/e495f1/32.png) [@erdemuguz1](https://community.wolfram.com/u/erdemuguz1)\
**Post date:** [July 2, 2016, 10:22am UTC](https://community.wolfram.com/t/avoid-protected-locked-private-package-warnings-from-this-code/8829/1 "2016-07-02T10:22:29Z")

</div>

Hello,  
I am trying to develop a CDF application using package in order to encode the contents. I do the development in stages; first .nb file of the code. After that I create the package from nb file by simply copy-paste the .nb file between

```
 BeginPackage["INT1D`"];
    Begin["`Private`"];
.
.
My code copied and pasted from .nb
End[];
SetAttributes[{all my functions},{ReadProtected,Protected,Locked}];
EndPackage[];

```

And from a nb file

```
Get[FileNameJoin[{NotebookDirectory[EvaluationNotebook[]], 
    "INT1D.wl"}]];
u = z^2 Sin[4 \[Pi] z]^3;
xL = 0; xR = 1; nprecision = 20; nd = 16; fp = False;
INT1D`D1[u, xL, xR, nprecision, nd, fp];

```

In this setup I do not get any output from my code unless I remove Begin[“`Private`”]; and corresponding End[]. Once I remove those I do get an output.

And no matter with or without Begin[“`Private`”]; command I get warnings about my Functions are being  
D1 in D1[u\_, xL\_, xR\_, nprecision\_, nd\_, fp\_] is Protected  
Symbol D1 is locked.  
I get these messages for all my functions.

I dont see what I am doing wrong in here. I would appreciate it if anyone can point out my mistake.

Thanks

Erdem

---

<div class="post-metadata">

**Author:** ![kubapod](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/kubapod/32/18662_2.png) [@kubapod](https://community.wolfram.com/u/kubapod)\
**Post date:** [July 2, 2016, 5:38pm UTC](https://community.wolfram.com/t/avoid-protected-locked-private-package-warnings-from-this-code/8829/2 "2016-07-02T17:38:26Z")

</div>

You need to export symbols to `INT1D` ` context by mentioning them between BeginPackage and Package. Otherwise everything is created in `INT1D`Private` ` which will not be on $ContextPath.

You can read more in

> **[Modularity and the Naming of Things—Wolfram Documentation](https://reference.wolfram.com/language/tutorial/ModularityAndTheNamingOfThings.html#5934)**
>
> The Wolfram Language normally assumes that all your variables are global. This means that every time you use a name like x, the Wolfram Language normally assumes that you are referring to the same object. Particularly when you write programs,...

and related tutorials or

[http://mathematica.stackexchange.com/questions/29324/creating-mathematica-packages](http://mathematica.stackexchange.com/questions/29324/creating-mathematica-packages)

---

<div class="post-metadata">

**Author:** ![erdemuguz1](https://avatars.discourse-cdn.com/v4/letter/e/e495f1/32.png) [@erdemuguz1](https://community.wolfram.com/u/erdemuguz1)\
**Post date:** [July 5, 2016, 1:49pm UTC](https://community.wolfram.com/t/avoid-protected-locked-private-package-warnings-from-this-code/8829/3 "2016-07-05T13:49:31Z")

</div>

Thank you for the reply. I created an example that mimics my actual problem in terms of the structure of the package. Here I used Private command without a problem. That is why I am little confused.

Here is that example.

```
Get[FileNameJoin[{NotebookDirectory[EvaluationNotebook[]], 
    "TFPackageSourceCodedifference.wl"}]];
Manipulate[
 DynamicModule[{f = Sin[x], xR = 1, xL = 0, 
   Res = 0.4596976941318603`16, NRes = 0.4596976941318603`16}, 
  Column[{Row[{"Lower Limit ", InputField[Dynamic[xL], Number]}, 
     Spacer[5]], 
    Row[{"Upper Limit ", InputField[Dynamic[xR], Number]}, Spacer[5]],
     Row[{"Function ", InputField[Dynamic[f]]}, Spacer[20]], 
    Button[Style["Calculate", Green, Bold], 
     Dynamic[Res = 
        TFPackageSourceCodedifference`WD1Int[f, xR, xL, np, nw];]], 
    Dynamic[NRes = 
       TFPackageSourceCodedifference`ND1Int[f, xR, xL, nw, np];], 
    Row[{"Result", InputField[Dynamic[Res], Enabled -> False]}, 
     Spacer[51]], 
    Row[{"Symbolic", 
      InputField[Dynamic[NRes[[1]]], Enabled -> False]}, Spacer[35]],
    Row[{"Difference", 
      InputField[Dynamic[NRes[[2]]], Enabled -> False]}, Spacer[35]]
    }]], {{np, 16, "NumberFormat"}, 
  ControlPlacement -> Bottom}, {{nw, 16, "WorkingPrecision"}, 
  ControlPlacement -> Bottom}, 
 Initialization :> (Get[
     FileNameJoin[{NotebookDirectory[EvaluationNotebook[]], 
       "TFPackageSourceCodedifference.wl"}]];)]

```

and the package

```
BeginPackage["TFPackageSourceCodedifference`"];
WD1Int::usage="";
ND1Int::usage="";
Clear[Global`x];
Begin["`Private`"];
WD1Int[f_,xR_,xL_,np_,nw_]:=Module[{xLcheck,xRcheck},xLcheck=NumberQ[xL];
xRcheck=NumberQ[xR];
If[xLcheck==True&&xRcheck==True,ResultTF=SetPrecision[NIntegrate[f,{Global`x,xL,xR},WorkingPrecision->Re[IntegerPart[nw]]],Re[IntegerPart[np]]],"Enter numeric inputs for Lower and Upper Limits"];
Return[ResultTF]];
ND1Int[f_,xR_,xL_,nw_,np_]:=Module[{xLcheck,xRcheck},xLcheck=NumberQ[xL];
xRcheck=NumberQ[xR];
numintwolf=WD1Int[f,xR,xL,np,nw];

If[xLcheck==True&&xRcheck==True,
ResultTFSym=SetAccuracy[Integrate[f,{Global`x,xL,xR}],nw];
DifferenceSymNum=ResultTFSym-numintwolf;

,"Enter numeric inputs for Lower and Upper Limits"];
Return[{ResultTFSym,DifferenceSymNum}]];

End[];
SetAttributes[{WD1Int,ND1Int},{ReadProtected,Protected,Locked}];
EndPackage[];

```

I dont know why using private does not create a problem without introducing the variable as you mentioned.

Erdem
