C:\_G\WWW\~ELISANET\INFO\tscmd103.html
<http://www.elisanet.fi/tsalmi/info/tscmd103.html>
Copyright © 2003- by Prof. Timo Salmi  
Last modified Fri 2-Nov-2018 09:40:33

 
Assorted NT/2000/XP/.. CMD.EXE Script Tricks
From the html version of the tscmd.zip 1cmdfaq.txt file
To the Description and the Index
 

This page is edited from the 1cmdfaq.txt faq-file contained in my tscmd.zip command line interface (CLI) collection. That zipped file has much additional material, including a number of detached .cmd script files. It is recommended that you also get the zipped version as a companion.

Please see "The Description and the Index page" for the conditions of usage and other such information.



103} How do I exit a loop by pressing a key?

You may wish to revisit item #14 first. Anyway:
  @echo off & setlocal enableextensions
  ::
  :: CHOOSE.EXE is a 16-bit executable

  if defined ProgramW6432 (
    echo/
    echo Exiting: %~f0 is incompatible with 64-bit Windows
    goto :EOF)
  ::
  :: Test for CHOOSE.EXE availability at path / in the current folder

  for %%f in ("CHOOSE.EXE") do set found_=%%~$PATH:f
  if exist CHOOSE.EXE set found_=CHOOSE.EXE
  if "%found_%"=="" (
    echo CHOOSE.EXE choice.com clone not found.
    echo Available from tscmd.zip
    goto :EOF)
  ::
  echo Press x to exit the loop
  ::
  :_loop
  set /a i_+=1
  choose /n /c:nx /tn,0 > nul
  if %errorlevel% NEQ 2 goto _loop
  ::
  echo i_=%i_% ^(cycles^)
  endlocal & goto :EOF

The output would be e.g.
  C:\_D\TEST>cmdfaq
  Press x to exit the loop
  i_=37 (cycles)

[Previous] [Next]

C:\_G\WWW\~ELISANET\INFO\tscmd103.html
C:\_G\WWW\~ELISANET\FTPCMD\TSALMI.CMD /tscmd103
http://www.elisanet.fi/tsalmi/info/tscmd103.html
file:///c:/_g/www/~elisanet/info/tscmd103.html