I can see that this is not documented anywhere, but NEXT actually accepts more arguments than just the counting variable name. The syntax is:
NEXT varname [atr] [filemask]
The atr and filemask are supposed to be the same as in the FOR var IN [atr] [filemask]. When these are not given, "all files" and "*.*" are assumed.
In other words, if the line starting the loop specifies attribute different than none ("all files") and/or a mask different than *.*, these must also be specified in NEXT:
for %d in +s *.FOO echo $%d next %d +s *.FOOI have no idea how this escaped the documentation. I will probably have to update the examples and let GoodByteXL know about it, so that this information will be reflected in next revisions of the User's Manual.
Super! Thanks for the explanation. I was just getting ready to make a posting saying I was suspecting the bug was somewhere in the for loop mechanism. As it happens, it's not so much a bug as an errata for the docs. And now that I'm aware of this, I have no problem using it in that way.
Just out of curiosity though, might it not make better sense to modify SDX to not require such specification in both the FOR and the NEXT, and instead just have it honor what was specified in the FOR? Unless there can be some kind of advantage I'm not imagining, it seems unnecessarily redundant.
But in any case, thank you for yet another even better version of SDX. It is one of the best contributions to the A8 community.