This is a suggestion for a new feature in the Set Variable actions (both the Calculation and Text versions.)
I would enjoy seeing (and use!) a new flag on the Set Variable actions (both the calculation and string versions) which looks like this:
![]()
/ ![]()
Trigger an error if the variable does not change
Of course, it would be disabled (
) by default, for compatibility with current code. With this new feature, I could write some code like this: (this is a simple example)
This would be extremely useful to me because I often need to know when a variable actually changes its value (I have a lot of variables that monitor things.) If I had this feature, I wouldn’t need to “store the previous value” and compare the previous value to the new value to detect if there is a change. That’s a lot of work. I would like my code to be cleaner, and this feature would help.
In most real-world cases that I face, I wouldn’t care if the variable is NOT changing value. I only care if the variable IS changing values, at which point I would notify the user through audio or visual feedback, like spoken text or a pop-up (using the Try Block, as shown above.)
Actually, I need this feature so often that I have a very useful macro that does this for me, but who likes to call a macro just to do a simple variable assignment? Not me.
SIDENOTE: In theory, one could also design this feature to trigger an error when the variable DOES change, rather than when it doesn’t. While this would be useful too, and I would still be happy with it, it seems simpler the way I’m recommending.
P.S. I’m not sure why the checkmark emoji came out a difference size from the X. Sorry.


