Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I apologize for post this as an answer instead of a comment, but my "comment" is too large...</p> <p>In the MS-DOS standard, all running programs have open these <em>Standard Handles</em>: 0-STDIN (keyboard), 1-STDOUT (screen), 2-STDERR (screen), 3-STDAUX (serial port) and 4-STDPRN (printer). Although Windows documentation clearly indicate that handles 3-9 are undefined, handle 3 have a special treatment by CMD.EXE. I have three reasons to think this:</p> <p>1- Handle 3 is connected to CON: device (keyboard for input, screen for output); handles 4-9 does not:</p> <pre><code>C&gt;ver Microsoft Windows XP [Version 5.1.2600] C&gt;echo To handle 3 &gt;&amp;3 To handle 3 C&gt;echo To handle 4 &gt;&amp;4 The handle could not be duplicated during redirection of handle 1. C&gt;set /P var=From handle 3: &lt;&amp;3 From handle 3: Value entered in keyboard C&gt;echo %var% Value entered in keyboard C&gt;set /P var=From handle 4: &lt;&amp;4 The handle could not be duplicated during redirection of handle 0. </code></pre> <p>2- The strange behavior of handle 3 stated in the present topic, that was solved in two differents ways. I discovered that if handles 0, 1 or 2 are redirected with handle 3 (and possibly handles 4-9), the redirection of handles 0, 1 or 2 becomes "permanent"; this behaviour doesn't happens if the handle 0, 1 or 2 are the <em>last</em> handle(s) in the list of redirections that include handle 3. This problem is entirely avoided if handles 0, 1 or 2 are redirected with handles 4-9 in any order, but not handle 3.</p> <p>3- The results obtained with my <a href="http://www.dostips.com/forum/viewtopic.php?f=3&amp;t=2800" rel="nofollow">TypeOfHandle.com program</a>. This program is a pure MS-DOS executable file that check the handle given in its parameter and return via errorlevel a value of 3 if the handle is connected to the CONsole device, or a value of 128 if the handle is redirected to a disk file. These are the results:</p> <pre><code>C&gt;typeofhandle 0 C&gt;echo %errorlevel% 3 C&gt;typeofhandle 0 &lt; anyFile.txt C&gt;echo %errorlevel% 128 C&gt;typeofhandle 1 C&gt;echo %errorlevel% 3 C&gt;typeofhandle 1 &gt; anyFile.txt C&gt;echo %errorlevel% 128 C&gt;typeofhandle 3 C&gt;echo %errorlevel% 0 C&gt;typeofhandle 3 &lt;&amp;3 anyFile.txt C&gt;echo %errorlevel% 0 C&gt;typeofhandle 3 &gt;&amp;3 anyFile.txt C&gt;echo %errorlevel% 0 </code></pre> <p>Handles 3-9 behaves strange in other aspect:</p> <p>The results obtained with my <a href="http://www.dostips.com/forum/viewtopic.php?f=3&amp;t=2823" rel="nofollow">SetFilePointer.com program</a>. Although handles 3-9 may be used in a Batch file to achieve input/output from/to several files at once, such mechanism only allows <em>sequential access</em> because my SetFilePointer program can't move the File Pointer of handles 3-9. SetFilePointer program correctly works on handles 0, 1 and 2; this feature allows to write a complete Relational Database application in Batch. This topic is described in detail at <a href="http://www.dostips.com/forum/viewtopic.php?f=3&amp;t=3126" rel="nofollow">this post</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload