[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

【出题】批处理逐字输出效果练习

  1. THEY CAME FIRST for the Coummunists,
  2.      and I didn't speak up because I wasn' t a Communist.
  3. THEN THEY CAME for the Jews,
  4.      and I didn't speak up because I wasn' t a Jew.
  5. THEN THEY CAME for the trade unionists,
  6.      and I didn't speak up because I wasn' t a trade unionist.
  7. THEN THEY CAME for the Catholics,
  8.      and I didn't speak up because I was a Protestant.
  9. THEN THEY CAME for me,
  10.      and by that time no one was left to speak up.
  11.                                      Pastor Martin Niemoeller
复制代码
显示速度每分钟200字母;代码尽量短小简洁;(注意文字内有很多重复短语)

回复 4# lfoqtal


    win7 下,你的代码空格不显示。
关于我的:
  1. @echo off
  2. setlocal enabledelayedexpansion
  3. for /f "skip=37 delims=" %%i in ('findstr /n .* %0') do (
  4. set "Mstr=%%i"
  5. set "Mstr=!Mstr:*:=!"
  6. call :逐字显示
  7. echo.
  8. )
  9. pause>nul
  10. :逐字显示
  11. call :FunDelay 200
  12. if defined Mstr (
  13. set "s=!Mstr:~0,1!"
  14. if defined s (
  15. set /p "=@!s!"<nul
  16. set Mstr=!Mstr:~1!
  17. goto 逐字显示
  18. )
  19. ) else (
  20. set /p "="<nul
  21. )
  22. goto :eof
  23. :FunDelay
  24. set beginTime=%time%
  25. set/a minute1=1%beginTime:~3,2%-100
  26. set/a second1=1%beginTime:~6,2%%beginTime:~-2%0-100000
  27. :LoopContinue
  28. set nowTime=%time%
  29. set/a minute2=1%nowTime:~3,2%-100
  30. set/a second2=1%nowTime:~6,2%%nowTime:~-2%0-100000
  31. set/a difMs=((%minute2%-%minute1%+60)%%60)*60000+%second2%-%second1%
  32. if %difMs% lss %1 goto LoopContinue
  33. goto :eof
  34. THEY CAME FIRST for the Coummunists,
  35.      and I didn't speak up because I wasn' t a Communist.
  36. THEN THEY CAME for the Jews,
  37.      and I didn't speak up because I wasn' t a Jew.
  38. THEN THEY CAME for the trade unionists,
  39.      and I didn't speak up because I wasn' t a trade unionist.
  40. THEN THEY CAME for the Catholics,
  41.      and I didn't speak up because I was a Protestant.
  42. THEN THEY CAME for me,
  43.      and by that time no one was left to speak up.
  44.                                      Pastor Martin Niemoeller
复制代码
精简肯定是谈不上了,
还有那个延时函数,挺庞大的

TOP

我试一下,做到了分行输出,就是字符之间有空隔,不知谁帮我改一下。
  1. @echo off
  2. setlocal enabledelayedexpansion
  3. for /f "delims=" %%i in (1.txt) do (
  4. set b=%%i
  5. for /l %%a in (0 1 100) do (
  6. set/p var=!var!!b:~%%a,1!<nul&set var=  
  7. for /l %%b in (0 1 300) do echo %%b>nul
  8. )
  9. )
  10. pause
复制代码

TOP

本帖最后由 lfoqtal 于 2011-8-14 14:43 编辑

吃螃蟹呀!
自认为不够精简,输出时间还行啦(包括空格的速度)
  1. @echo off&setlocal enabledelayedexpansion
  2. for /f "skip=16 delims=" %%a in (%0) do (
  3.       call :1 "%%a"
  4.       set b=0&echo.
  5.      )
  6. pause<nul
  7. goto :eof
  8. :1
  9. set "a=%~1"
  10. :2
  11. if "!a:~%b%,1!"=="" goto :eof
  12. set/p=!a:~%b%,1!<nul
  13. set /a b+=1
  14. for /l %%i in (1,1,100) do a 2>nul
  15. goto :2
  16. THEY CAME FIRST for the Coummunists,
  17.      and I didn't speak up because I wasn' t a Communist.
  18. THEN THEY CAME for the Jews,
  19.      and I didn't speak up because I wasn' t a Jew.
  20. THEN THEY CAME for the trade unionists,
  21.      and I didn't speak up because I wasn' t a trade unionist.
  22. THEN THEY CAME for the Catholics,
  23.      and I didn't speak up because I was a Protestant.
  24. THEN THEY CAME for me,
  25.      and by that time no one was left to speak up.
  26.                                      Pastor Martin Niemoeller
复制代码
通用简洁实用就是批处理精神

TOP

逐字母显示,就像键盘敲代码的效果。。。

TOP

这里的字是指单词还是字母呢?

TOP

返回列表