Scope of expression in a user-defined function

I have the following code:

fbasic = A + R + Z*Z *Z*Z;
f[A_, Z_, R_] := fbasic + R;
f[0, 2, 3]


The answer I am getting is

3 + A + R + Z^4


Which is not what I want because the fbasic is not replaced by the expression. How can I do that?

-
Try using Set rather than SetDelayed. –  b.gatessucks Aug 18 '13 at 14:45
Thanks so much. It works. Could you give me more information about the difference between := and =? I really appreciate your help. –  user8551 Aug 18 '13 at 14:52
By the way, if I use Set rather than SetDelayed, how can I call this function later? Because "fbasic"can be an arbitrary function. –  user8551 Aug 18 '13 at 15:04
–  belisarius Aug 18 '13 at 15:10

For example, use Set Delayed and arguments

fbasic[a_, z_, r_] := a + r + z^4;
f[a_, z_, r_] := fbasic[a, z, r] + r;
f[0, 2, 3]


Another option is:

fbasic = aa + rr + zz^4;
f[a_, z_, r_] := Evaluate[fbasic /. {rr -> r, aa -> a, zz -> z}] + r;
f[0, 2, 3]


Or:

fbasic = aa + rr + zz^4;
f[a_, z_, r_] := Block[{rr = r, aa = a, zz = z}, fbasic + r]
f[0, 2, 3]

-
Thanks for your kind help. But in my code, there is a loop. Sometimes I don't the expression of "fbasic" which is calculated by the previous one. How I define this kind of function? –  user8551 Aug 18 '13 at 15:12
@user8551 That seems another kind of question. Could you edit your question specifying the problem a little bit more? –  belisarius Aug 18 '13 at 15:18
Omit Evaluate? –  Michael E2 Aug 18 '13 at 15:22
The concept of my code is: I write a function to calculate the multidimensional numerical integration.The input is a function. The output is the value which is the numerical integration. The first part of the code is 'FNintegration[fbasic_] := f[A_, Z_, R_] := fbasic;.....' . fbasic is an arbitrary function of A,Z and R.I need to get the value with different A Z and R. That is why I define another function f[A_, Z_, R_]. I want to call this function later. Thanks for your kind help. –  user8551 Aug 19 '13 at 2:25