![]() |
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-09-23 22:09 |
47,812 topics / 349,917 posts / today 0 new / 48,274 members |
| DOS批处理 & 脚本技术(批处理室) » A Brief Analysis of the Helpless Signature Code |
| Printable Version 57,281 / 63 |
| Floor16 lxmxn | Posted 2006-10-20 00:04 |
| 版主 Posts 4,938 Credits 11,386 | |
|
Rather than saying that Brother Wunaihe's signature is amazing, it's better to say that Brother willsort's explanation is more wonderful…………=_= |
|
| Floor17 jieok3375 | Posted 2006-10-20 00:36 |
| 中级用户 Posts 130 Credits 282 From 广东 | |
|
Learned something……
|
|
| Floor18 chenall | Posted 2006-10-26 05:29 |
| 银牌会员 Posts 469 Credits 1,276 From 福建泉州 | |
|
After testing the code on the 13th floor, Chinese characters cannot be displayed normally.
|
|
| Floor19 chenall | Posted 2006-10-26 05:42 |
| 银牌会员 Posts 469 Credits 1,276 From 福建泉州 | |
|
The idea on floor 13 is good.
type %1 | find "" /V /N | findstr "^\[[0-9]*\]$" >C:\_tmp_.txt It can be considered to use. findstr /n "^$" %1 >C:\_tmp_.txt Then modify the code a bit and it will be perfect. |
|
| Floor20 chenall | Posted 2006-10-26 06:10 |
| 银牌会员 Posts 469 Credits 1,276 From 福建泉州 | |
|
Using the idea from floor 13), I wrote this version.
Finally solved the problem of blank lines). Should be considered the final perfect version bar? |
|
| Floor21 redtek | Posted 2006-11-06 22:40 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
|
I have enjoyed this wonderful content again, haha……
[ Last edited by redtek on 2006-11-6 at 10:42 PM ] |
|
| Floor22 yuanzijia08 | Posted 2006-11-18 11:05 |
| 初级用户 Posts 30 Credits 78 From 湖南湘潭 | |
|
Strong, quite strong!!!!! Kneel on one knee and admire
|
|
| Floor23 yuanzijia08 | Posted 2006-11-18 12:17 |
| 初级用户 Posts 30 Credits 78 From 湖南湘潭 | |
|
@echo off & setlocal EnableDelayedExpansion
for /f "delims=" %%l in (%1) do ( set line=%%l for /l %%i in (0,1,80) do ( set /p=!line:~%%i,1!<nul ping/n 1 127.1>nul ) echo. ) pause Why can't this code handle characters like !? Don't say it's because it's a special character, I want to understand the internal reason for not being able to handle it. Thanks |
|
| Floor24 redtek | Posted 2006-11-18 22:59 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
Originally posted by yuanzijia08 at 2006-11-18 00:17: ) Your code on floor 23 can run~: ) But it needs parameters, because you have "for /f "delims=" %%l in (%1)", which specifies %1 as the file name to read, So when running the above batch processing, you must specify a file name to read, for example: The code file.BAT on your 23rd floor The text file name to read.txt Run in the above way, then you can display the content of the read text file in an animated way~: ) ) Save the following content as a text file, then use your 23rd floor code to run and read this file. Name the above content as: A.TXT Your 23rd floor code.BAT A.TXT This way you can display it in animation~: ) ) The code on floor 23 cannot read the text content containing special characters, such as the equal sign =. Brother yuanzijia08 can first test the above content, and then consider writing code that can display special numbers after it is okay~: ) |
|
| Floor25 redtek | Posted 2006-11-18 23:27 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
|
Also:
) Why can't special characters be processed? It is because when trying to use the instruction set /p=!line:~%%i,1!<nul to display content containing special symbols (such as the equal sign =), the system will consider it an error. Why does the system consider it an error? We can break down the operation to see the cause of the error: Now suppose that!line:~%%i,1! takes a character that happens to be "=", then it is equivalent to you executing: At this time, the system will prompt: The above is the running result. But if you want to display an equal sign "=" and special symbols? As you can see above, the equal sign "=" can be displayed because a space is added in front of the equal sign "=" to be displayed ~:) …………Skip n analysis processes………… At this time, think about what will happen if I add a space in front in advance and then display the text? (Please do this experiment by yourself ~:) …………Skip n analysis processes………… (Actually, it is found that this does not achieve the desired display effect, which is too wasteful of length, haha...) (What to do?) (Think again...) (At this time, you will think, then how can I eliminate that extra space I added?) (At this time, you may remember the ASCII code special control characters - how to remember it? You use it more often, look at these contents more, and you absolutely can't remember it if you haven't read it) (Which special control characters can be used? - How do you know? Try them all once (because if you are interested, you will try them all once :)) (It was also mentioned in programming classes or when learning C language: special control characters such as \n \t...) (Recall...) (Very likely, in continuous experiments, I suddenly remembered that legendary "backspace" character, what is its ASCII code?) (It is in the ASCII code table) (After going through n processes... will think, how do I input this character "backspace"?) (There are many ways, use Debug, use vbs, use Ctrl+P in edit - wait, how do you know this Ctrl+p? ) (Many days or a few minutes, just try it, it is helpful, or seen in some information by chance, all are processes of experience summary) (Then, what to do next?) (The backspace character can be input and used, how to apply it?) (......After n steps of experiments, it will be found that why are all the characters not displayed and all shrunk together? ) (It turns out that backspace has deleted the just displayed content... Wait... Think again... Isn't this the legendary animation?) (After going through these steps personally - must play through all of them personally, learned: ASCII code special control characters display special control characters how to delay what is a delay variable skillful operations of for assignment of variables and how to "split" and "extract" parts of variables how to count how to input special control characters, very likely even learned the input of special characters and simple operations in Debug how to read files………… Too much, but all of this is not enough just to look good, that may only be superficially understood (this understanding can very well be memory helping you to memorize it dead, not thoroughly) Brother yuanzijia08, try it one by one yourself, this is the process of learning and self-enlightenment ~:) Although typing with Wubi input method is as fast as speaking, it is tiring after typing too many words ~: D |
|
| Floor26 yuanzijia08 | Posted 2006-11-19 11:28 |
| 初级用户 Posts 30 Credits 78 From 湖南湘潭 | |
|
Very, very, very grateful to Brother redtek for the explanation. It's explained so clearly. Really thank you. But I have a question. When I write batch processing, I always use Notepad. Like that bell character (that is, the special character input by Ctrl + G under CMD), how should I input that symbol into Notepad?
|
|
| Floor27 yuanzijia08 | Posted 2006-11-19 11:42 |
| 初级用户 Posts 30 Credits 78 From 湖南湘潭 | |
|
```batch
@echo off & setlocal EnableDelayedExpansion for /f "delims=" %%l in (%1) do ( set line=%%l for /l %%i in (0,1,80) do ( set /p=!line:~%%i,1!<nul ping/n 1 127.1>nul ) echo. ) pause The above code can handle characters like %, but cannot handle characters like!. But set /p=! <nul can display! in CMD, so when dealing with the! symbol, it should not be a syntax problem of set /p=. It feels like it should be a problem with variable delay. I can't figure out which part the problem is. Because I don't quite understand variable delay. Brother redtek, can you explain it? ``` |
|
| Floor28 redtek | Posted 2006-11-19 23:02 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
|
Regarding the problem that the "!" symbol cannot be displayed on floor 27, it belongs to an issue with the application of delay variables~ : )
When looking at the above code, it is an assignment containing the "!" symbol and this assignment is within the range where the delay variable is enabled~ : ) As for why it cannot handle "!", a demonstration of the delay variable is made, and you will know it by running it~ : ) After running the above demonstration about the delay variable, you will know that setlocal EnableDelayedExpansion is not just placed anywhere casually~ : ) After reading and running the above code, please carefully study the code of brother chenall on floor 8, and you will understand why he places setlocal EnableDelayedExpansion in a suitable position instead of just placing it at the beginning of the code~ : ) It can be seen that brother chenall's code has a very deep foundation in handling special characters and the application of delay variables~ : ) Then re-consider the signature code of the moderator. It seems simple with just one or two lines, but how much essence is condensed in it~ : ) [ Last edited by redtek on 2006-11-19 at 10:11 AM ] |
|
| Floor29 redtek | Posted 2006-11-19 23:16 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
|
) Reply to post 26:)
For how to input special control characters, please refer to the following posts: posts 12, 14, 15 and the entire post~:) How to use "\-/ " to represent a progress status? http://www.cn-dos.net/forum/viewthread.php?tid=24347&fpage=1 |
|
| Floor30 ccwan | Posted 2006-11-20 01:52 |
| 金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊 | |
![]() |
|
| Prev 1 2 3 4 5 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |