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-28 16:28
中国DOS联盟论坛 » DOS疑难解答 & 问题讨论 (解答室) » I keep coming here to ask questions, and I really feel embarrassed! View 851 Replies 3
Original Poster Posted 2004-12-17 00:00 ·  中国 山东 青岛 联通
初级用户
Credits 118
Posts 5
Joined 2004-09-13 00:00
21-year member
UID 31368
Gender Male
Status Offline
I ran into a problem.
I have a text file, and it looks like this:

2004121506.003
2004121606.014
Now I want to take one line from this text file, for example 2004121606.014, and then assign it to a variable.
How do I do that?
Floor 2 Posted 2004-12-17 00:00 ·  中国 山西 运城 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re myauto: Judging purely from your description, it is impossible to get enough constraints. For example, if we take “extract 2004121606.014 and assign it to a variable” literally, it does not seem to mean much, because it would seem that just set var=2004121606.014 would be enough. But what you clearly mean is not that, so please consider the following questions and provide appropriate constraints.
How is your text line determined? Is it determined before running by a user looking at the output, or during runtime by the program analyzing the output? What characteristics does your text line have? Is it simply a numeric line, or are there other characteristic strings before and after the number? What kind of information do you want to extract from the text line? The whole line of text, or just the numeric information, non-numeric information, or some other distributed information? This is the kind of information that should be provided when asking this sort of question. If there are other issues you think are necessary, please explain them in advance as well, because differences in this information can lead to very large differences in the solution program. And for batch files, handling a specific problem is always easier than handling a whole class of problems. If you want a general-purpose program, please also consider beforehand the cost of writing such a program, including a long wait, imperfect code, or even ending up with nothing.
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 3 Posted 2004-12-26 00:00 ·  中国 上海 静安区 电信
初级用户
Credits 148
Posts 18
Joined 2004-11-30 00:00
21-year member
UID 34236
Gender Male
Status Offline
Use the for command. For the specific usage, you can look online for a detailed introduction to for.
Floor 4 Posted 2004-12-29 00:00 ·  中国 浙江 温州 电信
初级用户
Credits 165
Posts 27
Joined 2004-11-11 00:00
21-year member
UID 33555
Gender Male
Status Offline
The OP's question sounds like he's being deliberately mysterious. Why not say why you want to “take one line from this text file, for example 2004121606.014, and then assign it to a variable”? What is the purpose? With such an irresponsible way of asking the question, it is almost impossible to get a correct answer!!
Forum Jump: