Oops! I just found that the situation is worst than I expected, the problem is not passing the parameters to a function, the problem is using variables at all with the "writevalue" while inside a user defined function.

Can someone have a look at this, I'm starting to get crazy!
_________________________
Regards