Seeing that Brother electronixtar posted the ColorDemo.cmd ( http://www.cn-dos.net/forum/viewthread.php?tid=35609&fpage=1 ), there is a line of code that uses findstr to display colorful characters. I really admire the senior's talent. I use findstr rarely. Tonight I found that the use of the /a parameter of this command is a bit strange. By checking the help with findstr /?, the explanation is:
/A:attr Specify the color attribute with hexadecimal digits. Please see "color /?"
Then look at color /?, the explanation is:
attr Specify the color attribute of console output
The color attribute is specified by two hexadecimal digits -- the first is the background, and the second is the foreground.
So, for the /a parameter of findstr, it should be entering two hexadecimal digits. But the actual situation is not like that. I have tried many times and found that four hexadecimal digits are valid (take the last four if there are more than four), while it is not the case after the color command. The latter two digits of these four are easy to understand, that is, as mentioned above, "specify the color attribute of console output", and the first two digits are for what? I found that they are used to control the display of the horizontal lines and vertical lines between the file name strings (including the following colon) (including whether they are present and thickness), but it doesn't seem to be all, because sometimes the first two digits will affect the latter two digits, causing the latter two digits to lose their specified color function (such as 2c04).
TEST: (It seems to form an arithmetic sequence with a common difference of 4)
1. (Horizontal line)
2. (Vertical line)
3. (Horizontal line + vertical line)
4. (Vertical line, note the comparison with the second case)
5. (Horizontal line + vertical line, note the comparison with the third case)
6. (Vertical line, note the comparison with the second and fourth cases)
7. (Horizontal line + vertical line, note the comparison with the third and fifth cases)
8. Changing to 200a has no horizontal and vertical lines.
9. There are more behind, such as: (it seems to be the same as 1c0a)
10. There are also some situations where "the table" has nothing at all, or a very thick vertical line appears at the far right end of the table. Also pay attention to the horizontal and vertical lines on the table border (under different parameters, the border lines may or may not be displayed). Also, sometimes when you slide the scroll bar of the cmd window up to look at the command execution results above and then look back, you will find that the results of the just-executed command below have actually changed! Paranormal event! (such as 5c0a)
Here is another test batch:
*********************************
Note:
The above conclusions are purely my personal views. Everyone can also try it. What is going on here?
My operating system is:
XP Professional 5.1.2600
[ Last edited by s11ss on 2007-11-23 at 10:35 PM ]
/A:attr Specify the color attribute with hexadecimal digits. Please see "color /?"
Then look at color /?, the explanation is:
attr Specify the color attribute of console output
The color attribute is specified by two hexadecimal digits -- the first is the background, and the second is the foreground.
So, for the /a parameter of findstr, it should be entering two hexadecimal digits. But the actual situation is not like that. I have tried many times and found that four hexadecimal digits are valid (take the last four if there are more than four), while it is not the case after the color command. The latter two digits of these four are easy to understand, that is, as mentioned above, "specify the color attribute of console output", and the first two digits are for what? I found that they are used to control the display of the horizontal lines and vertical lines between the file name strings (including the following colon) (including whether they are present and thickness), but it doesn't seem to be all, because sometimes the first two digits will affect the latter two digits, causing the latter two digits to lose their specified color function (such as 2c04).
TEST: (It seems to form an arithmetic sequence with a common difference of 4)
1. (Horizontal line)
findstr /a:040a . %systemdrive%\boot.ini*2. (Vertical line)
findstr /a:080a . %systemdrive%\boot.ini*3. (Horizontal line + vertical line)
findstr /a:0c0a . %systemdrive%\boot.ini*4. (Vertical line, note the comparison with the second case)
findstr /a:100a . %systemdrive%\boot.ini*5. (Horizontal line + vertical line, note the comparison with the third case)
findstr /a:140a . %systemdrive%\boot.ini*6. (Vertical line, note the comparison with the second and fourth cases)
findstr /a:180a . %systemdrive%\boot.ini*7. (Horizontal line + vertical line, note the comparison with the third and fifth cases)
findstr /a:1c0a . %systemdrive%\boot.ini*8. Changing to 200a has no horizontal and vertical lines.
9. There are more behind, such as: (it seems to be the same as 1c0a)
findstr /a:dd0a . %systemdrive%\boot.ini*10. There are also some situations where "the table" has nothing at all, or a very thick vertical line appears at the far right end of the table. Also pay attention to the horizontal and vertical lines on the table border (under different parameters, the border lines may or may not be displayed). Also, sometimes when you slide the scroll bar of the cmd window up to look at the command execution results above and then look back, you will find that the results of the just-executed command below have actually changed! Paranormal event! (such as 5c0a)
Here is another test batch:
@echo off
setlocal
set begin=%1
set end=%2
set step=%3
set colo=%4
if "%4" equ "" (
echo Four parameters:
echo 1. Start value (two hexadecimal): such as 04
echo 2. End value (two hexadecimal): such as 2c
echo 3. Common difference (decimal): such as 4
echo 4. Setting of the last two digits color (two hexadecimal): such as 0a
echo For example: %0 04 2c 4 0a
set begin=04
set end=2c
set step=4
set colo=0a
)
set/a n=0x%begin%
set t=test.tmp
pushd %tmp%
if exist %t% goto :test
for /l %%a in (1,1,5) do echo.^ >>%t%
:test
call :10to16 %n%
if %n% lss 16 (set v=0%r%%colo%) else (set v=%r%%colo%)
echo %v%
findstr/a:%v% . %t%*
echo.
set/a n+=%step%
if not %n% gtr 0x%end% goto :test
popd
pause
goto :eof
:10to16
set/a q=%1
:1c
set/a r=%q%%%16
set/a q=%q%/16
call set r=%%r:10=A%%
call set r=%%r:11=B%%
call set r=%%r:12=C%%
call set r=%%r:13=D%%
call set r=%%r:14=E%%
call set r=%%r:15=F%%
call set r%1=%r%%%r%1%%
if not %q% equ 0 goto :1c
call set r=%%r%1%%
set r%1=*********************************
Note:
The above conclusions are purely my personal views. Everyone can also try it. What is going on here?
My operating system is:
XP Professional 5.1.2600
[ Last edited by s11ss on 2007-11-23 at 10:35 PM ]


