This code works fine only if a
is not defined in the outside context:
getA[f_,total_]:=Module[{},
result=Solve[\!\(
\*SubsuperscriptBox[\(\[Integral]\), \(0\), \(255\)]\(f \[DifferentialD]i\)\)==total,a];
If[Length[result] == 0,Return[False]];
a/.First@result//N
];
plotShow[f_,max_]:=Module[{},
a=getA[f,max];
If[!a,Return[]];
Print[f];
Plot[f,{i,0,255}]
];
plotShow[i * a, 3500] (* => 0.107651 i & a plot*)
(* Now showPlot has polluted the outside context with a = 0.107651 *)
plotShow[i * a, 3500] (* => Solve::ivar: "0.107651 is not a valid variable." *)
How can I make the function plotShow
stop polluting the outside context?
plotShow[f_,max_]:=Module[{},...]
byplotShow[f_,max_]:=Block[{a},...]
- this is ok only as long asa
is empty) $\endgroup$