1) Give a description of the problem
I’m working on creating a “messages” tile on my SharpTools dashboard, which is currently updated by a HTTP Post from WebCore. It will show recent messages sent over from various pistons (e.g. “Clothes have finished drying,” “Trash pickup tomorrow,” etc.)
I have it successfully receiving strings sent over, but I’m trying to get WebCore to only send over the 3 most recent messages and am not sure how to tackle this.
2) What is the expected behaviour?
- Any piston can append the “@messages” global variable.
- When the @messages variable is updated, it trims some of the “older” messages so the variable isn’t a huge list of outdated messages. Each message is on a new line in the string.
3) What is happening/not happening?
Right now, I’m planning on using an expression to take the current value of “@messages” and add a new line to it. But, here is my question: I don’t want a massive list of old messages to go through. Only the last 3-5. If it’s not easy to “truncate” a variable based on lines, perhaps I can do so by characters? How do you recommend I do this?