Question: question on single level evaluation for variables inside a proc() vs. global

I need a small help again. I have a basic question. Not able to figure how to do this.
(I am a newbie in Maple)

Maple handles things little different inside a proc() vs. global. http://www.maplesoft.com/support/help/Maple/view.aspx?path=procedure

And I could not understand what this below means in plain English:

Within a procedure, during the execution of its statementSequence, local
variables have
single level evaluation. This means that using a variable
in an expression will yield the current value of that variable, rather than
first evaluating that value. This is in contrast to how variables are evaluated
outside of a procedure, but is similar to how variables work in other programming languages.

 

But here is my question. In global name space, A variable inside an expression will automaticaly
update to the current value of the the variable. So one can do this:

x:='x';z:='z';
expr:=3*z;
z:=solve(x-1=0,x);
expr;

and now expr will have value "3" and not "3 z" since "z" was assigned a new numerical value in between
as one can see. The same code inside a proc()  behave differently

f:=proc()
  local z,x,expr;
  expr:=3*z;
  z:=solve(x-1=0,x);
  expr;
  end proc:

f();

return "3 z" and not "3" as the case with global scope. I tried subs() insid the proc,
but still it did not work. What is the recommded way to handle this? I want "expr" to
use the most recent value of any variables inside it. I can't do sub(z=z,expr) ofcourse
since this makes no sense. I need the value of z inside expr to be updated.i.e. I need
to refresh "expr" somehow.

 thank you,

Please Wait...