> Originally Posted by *rconn* View Post <showthread.php?p=602#post602>
> You didn't provide the batch file contents.
> > v:\> for /l %z in (1601,1,2008) agetodate.btm %@makeage[%z-02-28]
> > 1601-02-28 00:00:00
> > [snip]
> > 1644-02-28 00:00:00
> Actually I did post it in the Sparklist forum. I'm going to try to
> attach it (seems to have worked!). Just in case I'll paste it below.
> It's cryptic for speed.
> I use a plugin @ISLEAP (=365|366). You'll need this:
> function isleap=`%@if[%@eval[%1 %% 4] NE 0 .or. (%@eval[%1 %% 100] EQ 0
> .and. %@eval[%1 %% 400] NE 0),365,366]`
WAD -- a Ctrl-C is *not* propagated back to parent commands. (Changing
this would be catastrophic for existing batch files and aliases!)
There is a special case when pressing a ^C in a batch file, in that you
are given the option of exiting the current batch file or all batch
files. However, it does *not* mean that the next command at the command
prompt will also be aborted.
After the ^C, the parser stops the batch file and returns to the FOR.
Since FOR doesn't (and shouldn't!) know that you pressed ^C, the only
thing it can do is check the return value of the batch file. Since you
didn't provide an ON BREAK, the return value is going to be the default (0).
If you want it to abort your FOR loop if you've aborted the at the
command prompt, you need to add something like this to the beginning of
the batch file:
on break quit 3
which will catch every ^C, return a 3 to the FOR, which will then abort
the loop. (FOR *always* aborts the loop if the target command returns a 3.)
p.s.: Your next question is going to be "Then why does it sometimes
break out of the FOR?" Because sometimes the ^C is during the batch
file initialization (or termination), so the ^C is sent to the current
command (which is the FOR).