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-07-15 02:17
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Closed] Batch script to read text line by line, please help experts to improve DigestI View 14,331 Replies 31
Original Poster Posted 2006-11-19 21:44 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
─────────── 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 ]
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 2 Posted 2006-11-19 22:57 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
Bumping my own thread!
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 3 Posted 2006-11-19 23:23 ·  中国 北京 朝阳区 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
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,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 4 Posted 2006-11-19 23:26 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
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 ]
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 5 Posted 2006-11-20 07:03 ·  中国 甘肃 甘南藏族自治州 合作市 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Hehe~ I like to first use sed -n 1p to read the line and then read the characters one by one
Floor 6 Posted 2006-11-20 07:53 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

  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_______________________

Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
ccwan +3 2006-11-25 23:29
Floor 7 Posted 2006-11-20 08:07 ·  中国 广西 贵港 电信
高级用户
★★
学无尽止
Credits 635
Posts 244
Joined 2006-04-15 05:07
20-year member
UID 53857
Gender Male
From 广西贵港
Status Offline
Hehe, I actually find this quite interesting. May I ask how to fix its display speed?
Floor 8 Posted 2006-11-20 08:09 ·  中国 甘肃 甘南藏族自治州 合作市 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
To echo, so special characters are not easy to handle
Floor 9 Posted 2006-11-20 10:06 ·  中国 北京 朝阳区 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
Top~~Brother lxmxn's animation reading is wonderful, you can read novels啦~ : )
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 10 Posted 2006-11-20 21:01 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
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 ]
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 11 Posted 2006-11-23 07:49
中级用户
★★
DOS之日
Credits 337
Posts 161
Joined 2006-11-04 05:27
19-year member
UID 69523
Gender Male
Status Offline
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
Floor 12 Posted 2006-11-23 08:46 ·  中国 北京 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
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,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 13 Posted 2007-01-12 12:38 ·  中国 北京 中国科学院研究生院
银牌会员
★★★
Credits 1,187
Posts 555
Joined 2006-12-21 07:35
19-year member
UID 74129
Gender Male
Status Offline
What a good thing!

It has solved one of my problems.
Thank you.
Floor 14 Posted 2007-01-19 05:08 ·  中国 北京 鹏博士BGP
新手上路
Credits 1
Posts 3
Joined 2007-01-17 09:26
19-year member
UID 76788
Gender Male
Status Offline
Good stuff
Floor 15 Posted 2007-01-19 05:47 ·  中国 北京 方正宽带
新手上路
Credits 14
Posts 7
Joined 2007-01-19 05:09
19-year member
UID 76975
Gender Male
Status Offline
Pretty good stuff~
Forum Jump: