|
ccwan
金牌会员
     
积分 2725
发帖 1160
注册 2006-9-23 来自 河北廊坊
状态 离线
|
『楼 主』:
[已结]逐行逐字阅读文本的批处理,请高手帮忙完善
使用 LLM 解释/回答一下
─────────── 版主提示 ───────────
21楼 namejm 所写代码是完美解决方案
─────────── 版主提示 ───────────
我做了一个批处理,让它读取文本文件的内容,逐行逐字显示,但我水平太低,无法使它完全按照原文本的格式显示,请高手帮忙。谢谢!
Last edited by bjsh on 2007-8-10 at 08:35 AM ]
─────────── Moderator Reminder ───────────
The code written by user namejm on floor 21 is a perfect solution
─────────── Moderator Reminder ───────────
I made a batch script that reads the content of a text file and displays it line by line and character by character, but I'm too inexperienced to make it display exactly according to the original text format. Please help, experts. Thank you!
Last edited by bjsh on 2007-8-10 at 08:35 AM ]
|

三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。 |
|
2006-11-19 21:44 |
|
|
ccwan
金牌会员
     
积分 2725
发帖 1160
注册 2006-9-23 来自 河北廊坊
状态 离线
|
|
2006-11-19 22:57 |
|
|
redtek
金牌会员
     
积分 2902
发帖 1147
注册 2006-9-21
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
每次读一行,但你并没有显示完一行后让它换新行的代码~:)
所以全连着显示了~:)
也就是说,你读取了一行文本内容后,
然后分解了这个变量,以便再逐字的显示在屏幕上(白底背景很漂亮~:),
但是,你如何知道你取的那一行显示完了?(知道那一行显示完了就可以再打一个换行符了)。
所以,是不是要主动的取完一行以后在这个变量的最后再加一个“标置结束“的符号以方便判断呢?
如果有一个 if 判断是否此行到了结尾,如果是打一个换行符 echo.
这样的方法在下面贴子的第8楼有示例~:)
详见: 无奈何签名代码略析
http://www.cn-dos.net/forum/viewthread.php?tid=18838&fpage=1
上面贴子从读文本内容到显示特殊符号的例子都已经非常全面啦~:)
Last edited by redtek on 2006-11-19 at 10:27 AM ]
Each time, read one line, but you don't have the code that makes it start a new line after displaying a line~ : )
So it's all displayed continuously~ : )
That is to say, you read the content of a line of text,
Then decompose this variable so as to display each character on the screen one by one (the white background is very beautiful~ : )),
But how do you know when the line you took has been displayed? (Knowing when the line is displayed is to be able to type a new line character again).
So, should we actively add a "marking end" symbol at the end of this variable after taking a line to facilitate judgment?
If there is an if judgment to see if this line has reached the end, if yes, type a new line character echo.
This method has an example on the 8th floor of the following post~ : )
See in detail: A brief analysis of the helpless signature code
http://www.cn-dos.net/forum/viewthread.php?tid=18838&fpage=1
The examples from reading text content to displaying special symbols in the above post are already very comprehensive~ : )
Last edited by redtek on 2006-11-19 at 10:27 AM ]
|

Redtek,一个永远在网上流浪的人……
_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._ |
|
2006-11-19 23:23 |
|
|
ccwan
金牌会员
     
积分 2725
发帖 1160
注册 2006-9-23 来自 河北廊坊
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
谢谢!正是看了后,才有此想法,试着玩儿的。主要是没有完全消化吸收啊!
Last edited by ccwan on 2006-11-19 at 11:36 PM ]
Thanks! It's precisely after reading that I had this idea and tried to play around. Mainly because I haven't fully digested and absorbed it yet.
Last edited by ccwan on 2006-11-19 at 11:36 PM ]
|

三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。 |
|
2006-11-19 23:26 |
|
|
vkill
金牌会员
     
积分 4103
发帖 1744
注册 2006-1-20 来自 甘肃.临泽
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
呵呵~我喜欢先sed -n 1p 读取行再啄字读取
Hehe~ I like to first use sed -n 1p to read the line and then read the characters one by one
|
|
2006-11-20 07:03 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
  『第 6 楼』:
使用 LLM 解释/回答一下
刚下午写的,因为不支持特殊字符的读取,所以没敢发上来。看见兄弟发这帖子,才发上来,各位高手见笑了。
把要读的文件拖放到 ReadTxt.BAT 文件上释放即可。
::_______________________ReadTxt.BAT_______________________
@echo off&setlocal ENABLEDELAYEDEXPANSION
FOR /F "DELIMS=" %%A IN ('type %1') DO (CALL;:__;"%%A")
endlocal&PAUSE&goto :EOF
::显示字符子函数————————————-
:__
SET A="%1"
SET B=0
if "%A%"=="" goto end
:BEGIN
IF NOT "!A:~%B%,1!"=="" (
SET/P=!A:~%B%,1!<NUL
PING 127.1 -N 1 >NUL
SET/A B+=1
GOTO BEGIN
) else (
:end
echo/&echo\
)
::_______________________ReadTxt.BAT_______________________
Just wrote it this afternoon. Because it doesn't support reading special characters, I didn't dare to post it. Seeing the brother post this thread, I just post it now. Please forgive me, all experts.
Drag and drop the file to be read onto the ReadTxt.BAT file to release it.
::_______________________ReadTxt.BAT_______________________
@echo off&setlocal ENABLEDELAYEDEXPANSION
FOR /F "DELIMS=" %%A IN ('type %1') DO (CALL;:__;"%%A")
endlocal&PAUSE&goto :EOF
::Display character sub - function————————————-
:__
SET A="%1"
SET B=0
if "%A%"=="" goto end
:BEGIN
IF NOT "!A:~%B%,1!"=="" (
SET/P=!A:~%B%,1!<NUL
PING 127.1 -N 1 >NUL
SET/A B+=1
GOTO BEGIN
) else (
:end
echo/&echo\
)
::_______________________ReadTxt.BAT_______________________
此帖被 +3 点积分 点击查看详情 评分人:【 ccwan 】 | 分数: +3 | 时间:2006-11-25 23:29 |
|
|
|
2006-11-20 07:53 |
|
|
chainliq
高级用户
    学无尽止
积分 635
发帖 244
注册 2006-4-15 来自 广西贵港
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
呵呵,我倒是觉得这个挺有意思的,请问如何修个它的显示速度呢?
Hehe, I actually find this quite interesting. May I ask how to fix its display speed?
|
|
2006-11-20 08:07 |
|
|
vkill
金牌会员
     
积分 4103
发帖 1744
注册 2006-1-20 来自 甘肃.临泽
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
要 echo ,所以特殊字符这个不好处理
To echo, so special characters are not easy to handle
|
|
2006-11-20 08:09 |
|
|
redtek
金牌会员
     
积分 2902
发帖 1147
注册 2006-9-21
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
顶~~lxmxn兄的动画阅读很精彩,可以看小说啦~:)
Top~~Brother lxmxn's animation reading is wonderful, you can read novels啦~ : )
|

Redtek,一个永远在网上流浪的人……
_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._ |
|
2006-11-20 10:06 |
|
|
ccwan
金牌会员
     
积分 2725
发帖 1160
注册 2006-9-23 来自 河北廊坊
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
lxmxn兄确实厉害!佩服并感谢。
这正是我想要得效果,多谢兄的代码!
看看能不能解决特殊字符问题。
Last edited by ccwan on 2006-11-21 at 12:30 AM ]
Brother lxmxn is really amazing! Admire and thank you.
This is exactly the effect I wanted, thank you brother for the code!
Let's see if we can solve the special character problem.
Last edited by ccwan on 2006-11-21 at 12:30 AM ]
|

三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。 |
|
2006-11-20 21:01 |
|
|
hxuan999
中级用户
   DOS之日
积分 337
发帖 161
注册 2006-11-4
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
看小说?真是个好主意,正好哪个高手用批处理也做个电子阅读器吧.
Reading novels? That's really a good idea. Just wonder if any expert can make an electronic reader with batch processing.
|

for /f %%h in (`echo hxuan`) do for /f %%x in (`echo hxuan`) do if %%h==%%x nul |
|
2006-11-23 07:49 |
|
|
redtek
金牌会员
     
积分 2902
发帖 1147
注册 2006-9-21
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
在PSP游戏机上看电子书多爽啊~:)
Last edited by redtek on 2006-11-22 at 10:31 PM ]
How cool it is to read e-books on a PSP game console~ :)
Last edited by redtek on 2006-11-22 at 10:31 PM ]
|

Redtek,一个永远在网上流浪的人……
_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._ |
|
2006-11-23 08:46 |
|
|
scriptor
银牌会员
    
积分 1187
发帖 555
注册 2006-12-21
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
好东西啊
有解决我的一个问题了
谢谢了
What a good thing!
It has solved one of my problems.
Thank you.
|
|
2007-1-12 12:38 |
|
|
stormback
新手上路

积分 1
发帖 3
注册 2007-1-17
状态 离线
|
|
2007-1-19 05:08 |
|
|
liuxin31554155
新手上路

积分 14
发帖 7
注册 2007-1-19
状态 离线
|
|
2007-1-19 05:47 |
|