China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-21 09:52
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » A Brief Analysis of the Helpless Signature Code DigestII View 56,320 Replies 63
Floor 16 Posted 2006-10-20 00:04 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

  Rather than saying that Brother Wunaihe's signature is amazing, it's better to say that Brother willsort's explanation is more wonderful…………=_=
Floor 17 Posted 2006-10-20 00:36 ·  中国 广东 东莞 电信
中级用户
★★
Credits 282
Posts 130
Joined 2006-09-20 22:25
19-year member
UID 63201
From 广东
Status Offline
Learned something……
~~~~好好学习
天天向上~~~~
Floor 18 Posted 2006-10-26 05:29 ·  中国 福建 泉州 电信
银牌会员
★★★
Credits 1,276
Posts 469
Joined 2002-12-23 13:00
23-year member
UID 586
Gender Male
From 福建泉州
Status Offline
After testing the code on the 13th floor, Chinese characters cannot be displayed normally.
QQ:366840202
http://chenall.net
Floor 19 Posted 2006-10-26 05:42 ·  中国 福建 泉州 电信
银牌会员
★★★
Credits 1,276
Posts 469
Joined 2002-12-23 13:00
23-year member
UID 586
Gender Male
From 福建泉州
Status Offline
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.
QQ:366840202
http://chenall.net
Floor 20 Posted 2006-10-26 06:10 ·  中国 福建 泉州 电信
银牌会员
★★★
Credits 1,276
Posts 469
Joined 2002-12-23 13:00
23-year member
UID 586
Gender Male
From 福建泉州
Status Offline
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?


@echo off
findstr /n "^$" %1 >~tmp.shw
find ":" ~tmp.shw 1>nul 2>nul||del ~tmp.shw
set /A "turn=1"
for /f "usebackq delims=" %%l in (%1) do (
if exist ~tmp.shw call :space
set line=%%l
call :show
set /A "turn+=1"
echo.)
del ~tmp.shw
pause
goto :EOF

:show
setlocal EnableDelayedExpansion
for /l %%i in (0,1,9999) do (
if "!line:~%%i,1!"=="" goto :EOF
set /p= !line:~%%i,1!<nul
ping/n 1 127.1>nul
)
goto :EOF

:space
findstr "^%turn%:$" ~tmp.shw>nul && (
echo.
set /A "turn+=1"
goto :space
)
goto :EOF
QQ:366840202
http://chenall.net
Floor 21 Posted 2006-11-06 22:40 ·  中国 北京 朝阳区 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
I have enjoyed this wonderful content again, haha……

[ Last edited by redtek on 2006-11-6 at 10:42 PM ]
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 22 Posted 2006-11-18 11:05 ·  中国 江西 南昌 电信
初级用户
Credits 78
Posts 30
Joined 2006-06-17 18:01
20-year member
UID 57168
Gender Female
From 湖南湘潭
Status Offline
Strong, quite strong!!!!! Kneel on one knee and admire
Floor 23 Posted 2006-11-18 12:17 ·  中国 江西 南昌 电信
初级用户
Credits 78
Posts 30
Joined 2006-06-17 18:01
20-year member
UID 57168
Gender Female
From 湖南湘潭
Status Offline
@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
Floor 24 Posted 2006-11-18 22:59 ·  中国 北京 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
Originally posted by yuanzijia08 at 2006-11-18 00:17:
@echo off & setlocal EnableDelayedExpansion
for /f "delims=" %%l in (%1) do (
set line=%%l
for /l %%i in (0,1,80) do (
Why can't this code handle characters like this! Don't say it's because of special characters, I hope to understand the internal reason for not being able to handle it, thank you
...



) 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.


I love Beijing Tiananmen~: )
I love the great China~: )
I love all the pretty girls in great China~: )~


  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~: )
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 25 Posted 2006-11-18 23:27 ·  中国 北京 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
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:

  

  set /p==<nul
  


  At this time, the system will prompt:
  

  C:\TEMP>set /p==
  The syntax of the command is incorrect.
  


  The above is the running result.

  But if you want to display an equal sign "=" and special symbols?
  

  C:\TEMP>set /p= =<nul
   =
  C:\TEMP>
  


  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
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 26 Posted 2006-11-19 11:28 ·  中国 江西 南昌 电信
初级用户
Credits 78
Posts 30
Joined 2006-06-17 18:01
20-year member
UID 57168
Gender Female
From 湖南湘潭
Status Offline
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?
Floor 27 Posted 2006-11-19 11:42 ·  中国 江西 南昌 电信
初级用户
Credits 78
Posts 30
Joined 2006-06-17 18:01
20-year member
UID 57168
Gender Female
From 湖南湘潭
Status Offline
```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?
```
Floor 28 Posted 2006-11-19 23:02 ·  中国 北京 朝阳区 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
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~ : )


@echo %dbg% off
:: Delay variable experiment~ : )


:: Enable delay variable
setlocal EnableDelayedExpansion

set "myname=abcdefg!!!!redtek"
echo Normal output: %myname%
echo Delay variable: !myname!
echo Can you see the symbols in the quotes? "!!!"
echo.
pause
echo.
echo.

:: Disable delay variable
setlocal disabledelayedexpansion

set "myname=abcdefg!!!!redtek"
echo Normal output: %myname%
echo Delay variable: !myname!
echo Can you see the symbols in the quotes? "!!!"
echo.
pause


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 ]
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 29 Posted 2006-11-19 23:16 ·  中国 北京 朝阳区 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
) 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
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 30 Posted 2006-11-20 01:52 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Forum Jump: