|The exclams are equivalent to percents, IF enabledelayedexpansion is active. if not, they no longer work. !a! is same as %a%, but it is now accessible inside a code-block. A code-block is any code inside (). I recommend a thorough study of these listings:|
They explain things better than i can. the other thing, for this code:
for /L %%a in (0 1 100) do (
if not defined v goto :eof
!work! is the incoming argument %1 (the string whose length we want to get).
the operation after "set v=" is extracting one byte from that string: ~%%a,1
and the byte extracted is advancing by one for every loop defined by the "for /L" parameters. %%a goes from 0 to (an arbitrary) 100 in increments of one. When the byte is null (v is not defined), then the loop exits with the length stored in var. %len% (or !len!)
The downside of "enabledelayedexpansion", in your application, is that it makes the use of "!" for any other purpose tricky and cumbersome. So your random-char generator has to deal with that issue, one way or another.
hope this helps. If you have specific questions later, i will try to contribute to the assistance dialogue of the forum. good luck with your project! :-)