MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Decalring the golbal variables in Packages

  • To: mathgroup at smc.vnet.net
  • Subject: [mg115946] Decalring the golbal variables in Packages
  • From: lightnation <lightnation at naver.com>
  • Date: Thu, 27 Jan 2011 03:39:26 -0500 (EST)

The coding is as in the following, Please take a look at
"Begin["`Global`"]; "
in the 4th line. Is this right or not? That is the question.

=========Package========================

BeginPackage["Work`MyPackages`cMode`"];
cMode::usage = "cMode[NEvanU_,NEvanL_,NEvanC_] returns the number \
of mode (propagation + evanescent) mode";
Begin["`Global`"];
cMode[NEvanU_, NEvanL_, NEvanC_] :=
  Module[{},
	NPropU = Floor[2*f*Take[a, l]*Sqrt[eps1*mue1]];
    NModeU = NPropU + NEvanU;
	NPropL = Floor[2*f*Take[b, s]*Sqrt[eps1*mue1]];
    NModeL = NPropL + NEvanL;
    NPropC = Floor[2*f*alpha*Sqrt[eps0*mue0]];
    NModeC = NPropC + NEvanC;
Return[{NModeU, NModeL, NModeC}]]
End[];
EndPackage[];

==============Execution in the Notebook==============================
Remove["`*"];
l = 4; s = 2;
a = {31/10^3, 12/10^3, 11/10^3, 23/10^3};
Tu = {40/10^3, 25/10^3, 20/10^3, 30/10^3};
b = {5/10^3, 5/10^3};
Tl = {55/10^3, 45/10^3};
alpha = 120/10^3;
Tup = Table[Sum[Tu[[i]], {i, 1, i}], {i, 1, l}];
Tlp = Table[Sum[Tl[[i]], {i, 1, i}], {i, 1, s}];
d = 6/10^3; h = 15.27/10^3;
eps0 = 1/((36*Pi)*10^9); mue0 = (4*Pi)/10^7;
epsr = 4; muer = 1;
eps1 = eps0*epsr; mue1 = mue0*muer;
f = 5*10^9; w = 2*Pi*f;
k0 = w*Sqrt[eps0*mue0]; k1 = w*Sqrt[eps1*mue1];
theta = 0;
kx = k0*Sin[theta];
kz = k0*Cos[theta];

{ModeU, ModeL, ModeC} = cMode[1, 1, 1]

==============error messages in the output=========
Take::normal: Nonatomic expression expected at position 1 in
Take[Work`MyPackages`cMode`Global`a,Work`MyPackages`cMode`Global`l]. >>


  • Prev by Date: Re: LinearRecurrence syntax
  • Next by Date: Re: Help with While Loop Function
  • Previous by thread: Re: Odd Behavior of GraphicsRow and GraphPlot
  • Next by thread: Re: a bug in Mathematica 7.0?