中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-17 03:38
47,813 topics / 349,903 posts / today 0 new / 48,259 members
DOS疑难解答 & 问题讨论 (解答室) » I keep coming here to ask questions, and I really feel embarrassed!
Printable Version  893 / 3
Floor1 myauto Posted 2004-12-17 00:00
初级用户 Posts 5 Credits 118
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?
Floor2 willsort Posted 2004-12-17 00:00
元老会员 Posts 1,512 Credits 4,432
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.
Floor3 wolfkin Posted 2004-12-26 00:00
初级用户 Posts 18 Credits 148
Use the for command. For the specific usage, you can look online for a detailed introduction to for.
Floor4 ultralqxq Posted 2004-12-29 00:00
初级用户 Posts 27 Credits 165
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!!
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023