Thanks, Szabolcs.
Well, the story behind my question is that I'm developing an environment for working with Boolean algebra in an engineering context. I've been fascinated by Boolean algebra since I read Boole's Laws of Thought when I was sixteen. I'm seventy now and I've used Boolean algebra (working by hand) to design circuits all my working life. This is a retirement project, so it's just for fun.
At the moment, I'm working on getting the sequential equations to step through their states.
Here is what is working now:
In[105]:= a = 5
Out[105]= 5
In[106]:= SetAttributes[test1, HoldAll]
In[107]:=
test1[expr_] :=
Block[{output, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o},
b = 23;
c = expr /. {Plus -> Times, Times -> Plus};
output = Print[c];
c
]
In[108]:= test1[a + a (b + a + (k + 7) z^3)]
During evaluation of In[108]:= a (a+23 a (7 k+z^3))
Out[108]= 5 (5 + 115 (7 k + z^3))
In[109]:= b
Out[109]= b
My variables are any of the lower-case letters plus their inverted forms (with an overbar). I found that I could declare them in the block and input expressions as I want. If I don't decare them first, this happens:
In[116]:= a = 5
Out[116]= 5
In[117]:= SetAttributes[test1, HoldAll]
In[118]:= test1[expr_] := Block[{output},
b = 23;
c = expr /. {Plus -> Times, Times -> Plus};
output = Print[c];
c
]
In[119]:= test1[a + a (b + a + (k + 7) z^3)]
During evaluation of In[119]:= 5 (5+28 (7 k+z^3))
Out[119]= 5 (5 + 28 (7 k + z^3))
In[120]:= b
Out[120]= 23
So the global value of a is used and the global value of b is set.
I'll investigate the context solution.
Eric