Is it possible to initialize local parameters, which have the property RetainsValue set? The first time, that the procedure/function is called, I would like the parameter to be initialized by a certain value. Afterwards, when the procedure/function is called again, I would like the parameter to keep the value from the previous procedure call.
If I set Initial data for the parameter, the behaviour of RetainsValue is lost and the parameters is initialized with that value in every call to the procedure.
Best answer by gdiepen
Not sure if there is a way to directly combine the RetainsValue AND Initial data, but you could easily create a workaround by using another local parameter isAlreadyInitialized. This parameter should also have the property RetainsValue.
In the code your procedure, you first check the value of the isAlreadyInitalized. If the value is 0 (default value), it means that the procedure is being called for the first time and you initialize all your other local parameters to their initial value. After that, you set the value of the isAlreadyInitialized to the value 1 (which it will keep because of the RetainsValue).
Next time the procedure is called, the initialization will not be called anymore because the parameter has the value 1 now.