Clearing a STRING variable

Use Case: To know if/when someone pushes 2 push buttons - each being used for firing off their respective routines once pushed (one for "Good Morning", the other for "Good Night"). Visually I just want to be able to know what times each button was pushed, then reset for the next day.

I'm using RM to set a STRING variable to display the status (and time) of each respective button when pushed in a SharpTools dashboard. Works like a charm. I've set an expiration time at Midnight to reset the status of these buttons for the next day & would simply like the current STRING variable to no longer display until that button is pushed again. Can't seem to figure out how to do that part.

Ideal scenario:
When Good Morning button pushed - clear out the Good Night STRING variable so nothing is displayed (since person is now up & about/not sleeping); conversely, when person pushes Good Night button - clear out the Good Morning STRING variable so nothing is displayed (since person is has gone to bed/no longer up & about).

Thoughts on how best to achive?

I'm not familiar with SharpTools. Is setting the variable to a space not an option?

I'm also not clear on do have 1 or 2 variables.

In RM I believe the relevant STRING variable operators are SET/REMOVE/REPLACE. I would think that REMOVE would do the trick but it didn't seem to work for me when I tried that. I could be doing something wrong. When you say "space" what do you mean? (sorry I'm very literal?

@mark1 I use string variables for my notifications. At the end of my rules when the condition clears that created the notification message in the variable, I SET the value to 'null' which empties it. On my SharpTools dash it usually just displays a hyphen (or you can edit the SharpTools tile so that when the value = null, the colour is the same as the background - works a treat)

In the text area "Select Variable to Set" I put a single space (literally hit the space bar once).

I think I tried that myself previously and had some issues which is why I now use 'null'. Setting the variable to 'null' will not display the word 'null'

1 Like

That seems to have done the trick. Brilliant my dear Watson - thx.

1 Like

I think I recall now why I had to use 'null' and not a space to clear a variable.

Setting the string value to a space did clear the variable. However I have conditions in my rules that need to check whether the variable has a value in it. Those If Variable is NOT ' ' conditions either didn't work or returned an error whereas If Variable is NOT 'null' worked as intended.

The only way to make a String variable have the empty string is to use remove, and remove %variable-name% for the variable in question. You can't set it to empty from entering any value. It could be that SharpTools treats "null" as a special case, but that would be weird if true (since that's a valid string value).

1 Like

Not that I'm aware of -- at least not intentionally! :laughing:

1 Like

Looks like I've been talking rubbish for a change! :grinning: I'm sure SharpTools used to work that way as I remember posting a 'bug' on the SharpTools forum when the word 'Null' appeared in my displayed variable.

I've looked again at my rules and my variable (that is displayed on the dashboards) is now set to '-' when there's no event.