Sorry. I thought I was remembering I had a fast solution to that, but I must have been thinking of this which does a reasonable job of looping through characters in a text.
So elaborating on that (this seems to work but it’s not really adequately tested, but it’s late…)
Include (-
[ textWipe t i;
for (i = 0 : BlkValueRead(t,i) : i++ ) BlkValueWrite(t,i,0);
];
-)
To repeat with/for (loopvar - nonexisting text variable) running/-- through/in words in/of (t - text) begin -- end loop: (-
{-my:0} = {t}-->0;
@push {-my:0};
{-my:1} = TEXT_TY_Temporarily_Transmute({-by-reference:t});
@push {-my:1};
for ( {-my:1} = BlkValueLBCapacity({-by-reference:t}) - 1 : {-my:1} >= 0 : {-my:1}-- ) if (BlkValueRead({-by-reference:t}, {-my:1})) { {-my:1}++; break; }
for ({-my:0} = 0, {-my:2} = BlkValueRead({-by-reference:t}, 0), {-my:3} = 0 : ({-my:0} <= {-my:1}) : {-my:2} = BlkValueRead({-by-reference:t}, ++{-my:0}))
if ({-my:2} && ({-my:2} ~= 32)) { BlkValueWrite({-by-reference:loopvar}, {-my:3}++ , {-my:2}); }
else for ( : {-my:3} : {-my:3} = 0, textWipe({-by-reference:loopvar})) {-block}
@pull {-my:1};
@pull {-my:0};
TEXT_TY_Untransmute({-by-reference:t}, {-my:1}, {-my:0});
-)
n.b.: this won’t work with text literals, e.g., repeat for w in words of "moby dick" [...] [this no work]
but this works:
let mb be "moby dick";
repeat for w in words of mb [...]