LEAVE quits btm

I have a DO loop inside an IFF. A LEAVE inside the DO is exiting my btm. This seems to have only started happening in the last week or so. Here is the file Foo.btm:
Code:
*setlocal
*unalias *
ver
do Filename in *
   echo %Filename
   leave
enddo
echo First loop done
iff isfile * then
   do Filename in *
      echo %Filename
      leave
   enddo
endiff
echo Second loop done
Here is the output:
Code:
C:\Sys\Bat>Foo.btm

TCC  28.02.17 x64   Windows 10 [Version 10.0.19043.1348]
7z.bak
First loop done
7z.bak

C:\Sys\Bat>
 
May 20, 2008
12,035
127
Syracuse, NY, USA
It's OK in v27. I imaging it's a due to Rex's recent experimental fix for LEAVE inside IFF inside DO.
 
Nov 21, 2021
4
0
Hello,

I've almost the same problem.

For a number of years I've used TCC Version 13. Because of some restrictions I now have to upgrade. Therefore I'm currently evaluating the latest TCC version 28 . (Currently I use Win10Pro, 64Bit, Version 21H2.)

The following code worked fine with TCC 13 in many examples and for years. But since I've been testing TCC 28 there have been a few cases where it fails. I think the 'leave' jumps back to a wrong position of the batch file:

Code:
do ... [maybe forever]
  ...
  if [condition] leave
  ...
enddo

In some cases it has helped to write the following instead of the one above (the 'leave' is now bracketed):

Code:
do ... [maybe forever]
   ...
   if [condition] (leave)
   ...
enddo

But there's another case where this does not work completely. The TCC-Window terminates whithout any error-message, when the do-loop should be exited. The example in more details: (The do-loop waits, until a specified file appears.)

Code:
@echo off
*setlocal
*unalias *
pushd
...
iff [condition1] then
   ...
else
   iff [condition2] then
      ...
   else
      ...
      do forever
         delay 1
         if isfile [specified filename] leave
      enddo
   endiff
   ...
endiff
...

In the upper example, it is of no use at all to put the 'leave' in brackets. Only the following works properly:

Code:
@echo off
*setlocal
*unalias *
pushd
...
iff [condition1] then
   ...
else
   iff [condition2] then
      ...
   else
      ...
      do forever
         delay 1
         iff isfile [specified filename] then
            leave
         endiff
      enddo
   endiff
   ...
endiff
...

Ok, this works. But a large batch file becomes visually confusing.

Best regards

Thomas
 

rconn

Administrator
Staff member
May 14, 2008
12,532
165
For a number of years I've used TCC Version 13. Because of some restrictions I now have to upgrade. Therefore I'm currently evaluating the latest TCC version 28 . (Currently I use Win10Pro, 64Bit, Version 21H2.)

The following code worked fine with TCC 13 in many examples and for years. But since I've been testing TCC 28 there have been a few cases where it fails. I think the 'leave' jumps back to a wrong position of the batch file:

Try it with 28.02.18 (updated today).
 

Similar threads