Hi,
in my workout-TW I got now graphs working and for these graphs (for tracking progress visually) I need to append strings into dictionary-data-tiddlers by button.
All this is working fine
My question now:
Is it possible & how, to automatically delete the first lines, when the limit of 30 lines is reached?
So that there are never more than 30 value-pairs (the latest 30)?
This is my button for appending the value-pairs:
Maybe, I could do that by adding anything to the filter?
The lf variable holds a linefeed character (ASCII 10). There is no need for a carriage return (ASCII 13).
The first $action-setfield uses splitregexp[\n] to break the “TiddlerName” text into separate lines and keeps only the last 29 items. It then re-joins those items, separated by linefeed chars, and re-writes the text of “TiddlerName”.
Note that if there are currently less than 30 items, the “TiddlerName” text remains unchanged.
The second $action-setfield then adds the new index and value to the end of the “TiddlerName”.
I tried both and both are working, but also both not completely as my goal.
If already an entry /a line exists, than it appends the wished entry like it should f.e. 6-15:3in a new line.
But if the target tiddler (here “Tiddlername”) does not yet exist or is empty, than it inserts the entry 6-15:3with a blank line before, so the first line is empty. Then the graph cannot read the values.
I cannot say, if it inserts a blank line as first line, if the “TiddlerName” does not yet exist, because this button creates a tiddler with type application/json with the entry { "6-15": "3" }. But when I then change the type to application/x-tiddler-dictionary and click the button, then the entry is like it should. Except, that it adds a space after the :, so it writes 6-15: 3 instead of 6-15:3, and then the graph cannot read the values.
And I forgot to mention in the first post:
If the target tiddler does not yet exist, then the button should create that tiddler with the type application/x-tiddler-dictionary.
And also I would prefer a solution without macro, because I need to write this button with different “Tiddlernames” and {{!!rir}}is also often another field. And also often I will set not only 1 tiddler, but 3 tiddlers in this way with only this one button.
So, I think, this is not possible by macro.