Some hours after my original post, I edit that post: I'm sorry, but my code is nonsense. Of course I am interested in the value of exp WITHIN my functions and not after the functions being called. I will come back with a corrected version.
I have some global symbolic expression exp=a*x and want to substitute a within a function f[a_] by the parameter a. See the code below. The first three cases #1,#2,#3 are on the global level and work as expected. The following cases are within functions and I do not understand why they don't work as I expect. I'm afraid I have some basic misunderstandings with things like Evaluate, Hold, etc. and even Module.
#4 is a simple function without Module. It does not substitute the parameter a within exp. Why? But this can be cured through Evaluate as in #5.
The cases #6, #7, #7S use functions defined as modules and do never work. Not without and not with Evaluate. Why?
Case #7S is different from all others since it uses a symbolic parameter a=myA instead of a number. This does not work either.
Maybe I should try things like Replace, Eliminate, PolynomialReduce?
If[True,
ClearAll["Global`*"];
exp = a*x; Print["#1: Global exp: ", exp, "\n\tok"];
a = 3; Print["#2: a=3 substituted: ", exp, "\n\tok"];
a =.; Print["#3: a reset: ", exp, "\n\tok"];
f4[a_] := exp;
Print["#4: a=3 substituted within a function: " f4[3],
"\n\tNOK! Should give 3*x"];
f5[a_] := Evaluate[exp];
Print["#5: a=3 substituted within a function with Evaluate: ", f5[3],
"\n\tok"];
f6[a_] := Module[{}, exp];
Print["#6: a=3 substituted within a function-Module: ", f6[3],
"\n\tNOK! Should give 3*x"];
f7[a_] := Module[{}, Evaluate[exp]];
Print["#7: a=3 substituted within a function-Module with Evaluate: ",
f7[3], "\n\tNOK! Should give 3*x"];
Print["#7S: a=myA substituted within a function-Module with \
Evaluate: ", f7[myA], "\n\tNOK! Should give myA*x"];
]
#1: Global exp: a x
ok
#2: a=3 substituted: 3 x
ok
#3: a reset: a x
ok
#4: a=3 substituted within a function: a x
NOK! Should give 3*x
#5: a=3 substituted within a function with Evaluate: 3 x
ok
#6: a=3 substituted within a function-Module: a x
NOK! Should give 3*x
#7: a=3 substituted within a function-Module with Evaluate: a x
NOK! Should give 3*x
#7S: a=myA substituted within a function-Module with Evaluate: a x
NOK! Should give myA*x