Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

ENDDO mixup?

May
13,834
211
This BTM works as it should until the end of the outer DO loop. When j becomes 3, it branches to the command after the INNER "enddo".

Code:
do j=1 to 2
    timer /q
        do i=10 to 1 by -1 | (wsl sort -n ^| wc -l)
            echo %i
        enddo
    timer
    echo.
enddo

Code:
v:\> wsltotest.btm
10
Timer 1 off: 18:32:57  Elapsed: 0:00:00.185

10
Timer 1 off: 18:32:57  Elapsed: 0:00:00.085

Timer 1 on: 18:32:57

TCC: V:\wsltotest.btm [8]  Unknown command "enddo"

v:\>
 
You can pipe *out* of a command group, but you can't pipe *into* one. The parser is trying to get the first argument after the | to execute, which is "(wsl". It can't find it, so it tries to execute it by calling a child TCC process:

Code:
"D:\\TakeCommand26\\x64\\Debug\\TCC.EXE\" /c  (wsl sort -n ^| wc -l)

Which probably isn't what you intended, and which messes up your DO counters.
 
This syntax works but it doesn't seem intuitive to me and I'll probably forget it before I need it again.

Code:
v:\> type test.btm
do j=1 to 2
    timer /q
        do i=10 to 1 by -1 | `wsl sort -n ^| wc -l`
            echo %i
        enddo
    timer
    echo.
enddo

v:\> test.btm
10
Timer 1 off: 22:10:46  Elapsed: 0:00:00.183

10
Timer 1 off: 22:10:46  Elapsed: 0:00:00.081
 
Back
Top