WinDev procedure parameters are passed by reference as a default and this is great but can also cause some strange issues in your code if you are not careful.
There are a few ways to pass an object by value and one of my favourite is using the LOCAL statement when defining your parameters.
Here’s an example:
If you don’t define anything as LOCAL then you can also tell WLanguage that you are passing by value just by adding brackets around the object you are passing:
CalculateWinnerPrizeTotals((nWinnerID), xCost)
So the example above shows how you can tell the method you are passing nWinnerID by value and not by reference.


November 25th, 2009 at 11:46 pm
What kind of strange issues can cause parameters by reference?
November 26th, 2009 at 12:14 pm
Passing an object by reference is not an issue its part of how WLanguage works.
So for example, your had a variable called nValue with the value 5 and you called a method passing that variable:
nValue is int = 5
TestMethod(nValue)
In TestMethod you changed nValue to be 10 then the code would display a dialog with the value 10.
nValue is int
TestMethod(nValue)
Info(nValue)
If you setup your procedure to get the object by value then the result would have been 5 as the method does not change the object that was passed, it take a copy of the object.
November 26th, 2009 at 3:34 pm
I get it! Thank you very much. I like your windev/webdev articles.
Best regards.