anchor.diff:  echo.
   echo Options:
   echo   -?    Display this help
  +echo   -l    Capture the last non-empty line. Default: Build a list w. all such lines
   echo   -q    Quiet mode: Don't display the set command executed
   echo   -X    Display the command generated, but don't run it
   echo.
   echo In the first usage case, special characters can be entered in arguments as html-like entities.
   echo For that, surround the [entity] name in brackets instead of html's ^&entity;. Supported entities:
  -echo   [percnt]=%% [excl]=^! [quot]=" [hat]=^ [lt]=< [gt]=> [amp]=& [vert]=| [lpar]=( [rpar]=) [lbrack]=[ [rbrack]=]
  +echo   [percnt]=%% [excl]=^! [quot]=" [hat]=^ [lt]=< [gt]=> [amp]=& [vert]=| [lpar]=( [rpar]=) [lbrack]=[ [rbrack]=] [tab]=\t
   echo.
   echo The second usage case allows capturing the output of a complex sequence
  -echo of commands with several pipes. But the performance isn't as good.
  -echo.
  -echo In both cases, tricky characters like "^&<|> may cause unexpected results.
  +echo of commands with pipes. But the performance isn't as good.
  +echo.
  +echo In both cases, tricky characters like "^&<|>!%% may cause unexpected results.
   exit /b
   
   :#----------------------------------------------------------------------------#
  
positive.code: 
  :#############################################################################:
  End of the JScript comment around the Batch section; Beginning of the JScript section */
  
  /* Process JScript command-line arguments */
  function main(argc, argv) {
    var keys = "";
    for (var i = 1; i < argc; i++) {
      var arg = argv[i];
      // WScript.Echo("JScript args[" + i + "] = " + arg);
      /* Escape the reserved characters for use by SendKeys */
      if (keys != "") keys += " ";
      for (var j = 0; j < arg.length; j++) {
        var c = arg.charAt(j);
        switch (c) {
        case '+':
        case '~':
        case '(':
        case ')':
        case '{':
        case '}':
  	c = "{" + c + "}";
  	break;
        case '^':
        case '%':
  	c = "{" + c + "}";
  	c = c + c;
  	break;
        }
        keys += c;
      }
    }
    var shell = WScript.CreateObject("WScript.Shell");
    shell.SendKeys("set " + keys + "{ENTER}");
  }
  
  /* Top level code, building a C-like environment */
  
negative.code: :# I tried using known tricks like '(goto) 2>NUL' but this did not help.
  :# As a workaround, I'm now using JScript to generate a set command that's
  :# fed back into this shell's keyboard input stream.
  %SENDKEYS%
  
  %IF_NOEXEC% set "RESULT=%%RESULT%%"
  endlocal & endlocal & %EXEC% %SET% %VAR%=%RESULT%
  exit /b
  
  :# Capture only the last non-empty line
  :CaptureLast
  endlocal & %EXEC% for /f "delims=" %%v in ('%CMDLINE%') do %SET% %VAR%=%%v
  exit /b
  
  