# Symbol created in Module not seen outside of Module scope [duplicate]

I am using a function defined with a Module[]. In the Module I am creating a new variable name using a Symbol[] function. I would like to reuse the created symbol outside the function call, namely here: varf in the following lines of code:

f[a_] := Module[{var}, var = a; vart = 44; Symbol["var" <> "f"] = 3]


The function returns 3, if I call vart I get 44. If I call var I don't get value of a. If I call varf I get varf.

Can somebody help?

• Have you noticed "Set::write: Tag Symbol in Symbol[varf] is Protected."? Anyway, take a look at How to create symbols from strings and set values for them? – Kuba Nov 18 '18 at 15:16
• Yes, that error popped out, but when I called Context[varf] I got Global for a response. – brnady Nov 18 '18 at 16:01
• Because it was created when you called Context. – Kuba Nov 18 '18 at 16:21
• So you are suggesting that I replace all Symbol[] with RawBox[] and whenever I have a value assignment that I add a wrapper ToExpression@MakeBoxes[...] around the assignment command? – brnady Nov 19 '18 at 11:00
• I am suggesting that when you want to assign a value to a symbol generated from a string, then read the linked topic. If you should do this depends of your use case, it is usually better to use Indexed as opposed to symbol generation. – Kuba Nov 19 '18 at 12:04