Am 23.12.20 um 12:00 schrieb Brian Revell:
Is there any way to update variables that are functions of another,
if
the original variable Y has been amended or updated . The former is
straightforward to edit Y's values. But I am not clear that for
example, l-Y is automatically recalculated. And if l-Y has already
been used in a session, Gretl will not let it be deleted giving the
error message cannot be deleted variable in use..
Suggestions around this issue welcomed
Hi Brian,
Nothing gets automatically re-computed -- which is good. If you want to
re-compute anything, you should make use of a function which needs to be
called each time you have new/ different input variables. See the
following example.
With rehard to your second point: Could you give an example please?
<hansl>
scalar X = 4
scalar Y = 3
scalar Z = X - Y
print X Y Z
# changes in Y do not affect previously assigned Z
scalar Y = 2
print X Y Z
# Make use of a function for 'updating' Z
function scalar compute_z (scalar X, scalar Y)
return X - Y
end function
scalar Y = 3
eval compute_z(X, Y)
scalar Y = 2
eval compute_z(X, Y)
</hansl>
Artur