It looks like you're new here. If you want to get involved, click one of these buttons!
<span id="warning"></span> <<silently>> <<set $min = 0, $max = 12>> <<repeat 100ms>> <<set $warn = $warnings.substr($min, $max)>> <<set $min++, $max++>> <<if $max gt 185>> //Hardcoded string-length <<set $max = 12, $min = 0>> <</if>> <<replace "#warning">>$warn<</replace>> <</repeat>> <</silently>>It works, buuut it behaves oddly. For some reason, the gap between min & max becomes larger, making the length of the substring longer, the longer it runs, until $max hits the if-statement, where the substring starts shrinking. Once the substring's length is 0, it repeats again.
Comments
The main issue with your example is that you're using Javascript's substr() method , which expects a length as it's second parameter and you're supplying an end-point. You can either change how you calculate the second parameter's value or switch to using the substring() method instead.
The following is a slightly modified and a little more generic version of your example, which also handles the reset event a little better. ... the above also includes a condition that stops the <<repeat>> macro after a set number of loops, which I do because time based looping can interfere with a user's ability to interact with the screen.
note: It would be relatively easy to convert the above into a <<widget>> that accepts 3-4 parameters. eg. The message, the slices size, the target element, number of loops.
Works like a charm.
And I'll remember to add full version numbers next time.