![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-08 21:14 |
47,811 topics / 349,895 posts / today 0 new / 48,253 members |
| DOS批处理 & 脚本技术(批处理室) » [Discussion] ********Question about the Usage of findstr/a******** |
| Printable Version 4,803 / 23 |
| Floor1 s11ss | Posted 2007-11-23 22:19 |
| 银牌会员 Posts 566 Credits 2,098 | |
|
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 ] |
|
| Floor2 knoppix7 | Posted 2007-11-24 12:30 |
| 银牌会员 Posts 634 Credits 1,287 From cmd.exe | |
|
It's very similar to debug in DEBUG..
f b800:0000 f9f XX YY It seems that XX represents the style and YY represents the color. |
|
| Floor3 s11ss | Posted 2007-11-24 17:42 |
| 银牌会员 Posts 566 Credits 2,098 | |
|
Oh? I think this feature can be used to draw tables..................
|
|
| Floor4 electronixtar | Posted 2007-11-27 19:48 |
| 铂金会员 Posts 2,672 Credits 7,493 | |
|
Wow咔咔, it's a rare technical post, I really can't bear to water it down.
That ColorDemo.CMD wasn't written by me, I just reposted it, and I'm not any senior, just an enthusiast for p processing. |
|
| Floor5 zh159 | Posted 2007-11-27 20:07 |
| 金牌会员 Posts 1,467 Credits 3,687 | |
|
Now 10to16 doesn't need to be so wordy. If you only convert one digit (0~f), just use the following:
For converting multiple digits: [ Last edited by zh159 on 2007-11-27 at 08:09 PM ] |
|
| Floor6 s11ss | Posted 2007-11-27 20:08 |
| 银牌会员 Posts 566 Credits 2,098 | |
Originally posted by electronixtar at 2007-11-27 07:48 PM: Brother electronixtar, don't be modest~~ Hey, in your signature cmd /cstart "" "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>" Why do I get a "No page to display" prompt when I run this? Also, what are the usages of about:? |
|
| Floor7 electronixtar | Posted 2007-11-27 20:11 |
| 铂金会员 Posts 2,672 Credits 7,493 | |
Originally posted by s11ss at 2007-11-27 20:08: Then just run iexplore about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'> and try it? Wow haha [ Last edited by electronixtar on 2007-11-27 at 08:19 PM ] |
|
| Floor8 electronixtar | Posted 2007-11-27 20:16 |
| 铂金会员 Posts 2,672 Credits 7,493 | |
Originally posted by zh159 at 2007-11-27 20:07: :P I don't understand, awesome, I haven't been here for a long time and the experts are still so powerful |
|
| Floor9 upsco | Posted 2007-11-27 20:25 |
| 初级用户 Posts 32 Credits 67 | |
Originally posted by electronixtar at 2007-11-27 08:11 PM: We can't get it to run no matter how we reference it. If we could run some program on your computer like this, heh heh, you'd be in trouble |
|
| Floor10 electronixtar | Posted 2007-11-27 20:28 |
| 铂金会员 Posts 2,672 Credits 7,493 | |
Originally posted by upsco at 2007-11-27 20:25: Then you must not have installed any version of Microsoft Office 2000/XP/2003/2007 |
|
| Floor11 s11ss | Posted 2007-11-27 20:30 |
| 银牌会员 Posts 566 Credits 2,098 | |
|
Brother zh159, your code for converting multiple digits isn't necessarily less wordy than mine~~~~~~~~
No, I take that back. Actually, each has its own advantages and disadvantages. Yours is simple but reduces code readability, and mine is wordy but improves code readability. [ Last edited by s11ss on 2007-11-27 at 08:46 PM ] |
|
| Floor12 s11ss | Posted 2007-11-27 20:33 |
| 银牌会员 Posts 566 Credits 2,098 | |
Originally posted by electronixtar at 2007-11-27 08:28 PM: I installed Microsoft Office 2003. It seems to be a modified version. |
|
| Floor13 zh159 | Posted 2007-11-27 20:42 |
| 金牌会员 Posts 1,467 Credits 3,687 | |
| Floor14 s11ss | Posted 2007-11-27 20:51 |
| 银牌会员 Posts 566 Credits 2,098 | |
|
Brother zh159, your code for converting multiple digits is no less wordy than mine~~~~~~~~
I'm sorry, I take that back. Actually, each has its own advantages and disadvantages. Yours is simple but reduces code readability and increases "program processing volume" (replaces 0-9), and mine is wordy but improves code readability. |
|
| Floor15 everest79 | Posted 2007-11-27 20:54 |
| 金牌会员 Posts 1,127 Credits 2,564 | |
|
I also wrote one
SETLOCAL ENABLEDELAYEDEXPANSION IF %1 GTR 2099999999 (GOTO :EOF) SET VAR=0123456789ABCDEF FOR /L %%i IN (0,1,15) DO ( SET H%%i=!VAR:~%%i,1! SET HH=1&SET KK=0&SET TT=%1 :th1 SET /A HV%HH%=%TT%/16,HV%KK%=%TT%%%16 IF !HV%HH%! GTR 16 (SET TT=HV%HH%&&SET /A HH+=1,KK+=1&&GOTO TH1) SET VAR1=0x00!H%HV9%!!H%HV8%!!H%HV7%!!H%HV6%!!H%HV5%!!H%HV4%!!H%HV3%!!H%HV2%!!H%HV1%!!H%HV0%! ECHO %VAR1% ^<^<=%0 GOTO :EOF |
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |