中国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-09 15:41
47,811 topics / 349,896 posts / today 1 new / 48,254 members
DOS批处理 & 脚本技术(批处理室) » Been racking my brains, finding the largest number in Notepad
Printable Version  1,954 / 17
Floor1 dragonamd Posted 2008-08-23 02:22
中级用户 Posts 100 Credits 209
In Notepad it's all numbers like 1-2.044 2-3.044 3-5.044 4-2.084 5-2.44 5-6.02 3-5.404
Numbers like this, and there is no pattern. How should I do it to get the largest number? The requirement is numbers starting with 5, and take the largest number after the 5. It's a segment like 5-6.02 5-2.44 and the result after comparison should be 5-6.02 and display it.

[ Last edited by dragonamd on 2008-8-23 at 02:25 AM ]
Floor2 moniuming Posted 2008-08-23 11:26
银牌会员 Posts 574 Credits 1,335 From 广西
If it is one string of numbers per line, like below, please try this:
1-2.044
2-3.044
3-5.044
4-2.084
5-2.44
5-6.02
3-5.404


Floor3 pusofalse Posted 2008-08-23 11:32
银牌会员 Posts 646 Credits 1,604
Floor4 dragonamd Posted 2008-08-23 12:39
中级用户 Posts 100 Credits 209
pusofalse, your code works a bit better, but it still has a flaw: it displays as one line, hehe
5-2.44 3-5.144
5-6.02 3-5.444
3-5.404 5-7.244
With a format like this it can't detect it also if next time I want to define the first letter to detect myself, how should I modify it
Floor5 pusofalse Posted 2008-08-23 12:43
银牌会员 Posts 646 Credits 1,604
You mean there are two columns in one line?
Floor6 dragonamd Posted 2008-08-23 12:50
中级用户 Posts 100 Credits 209
Many columns, at least around 7-8 columns I guess
Floor7 pusofalse Posted 2008-08-23 12:58
银牌会员 Posts 646 Credits 1,604
As long as the first number in the first column is 5, and the value after that 5 in the first column is the largest, then output the whole line. Is that my understanding correct?
Floor8 dragonamd Posted 2008-08-23 13:09
中级用户 Posts 100 Credits 209
No, not taking out a whole line, just taking out something like 5-7.244 is enough
It's not the first number in the first column, but all of them. What I'm taking is indeed the part after 5-
Floor9 pusofalse Posted 2008-08-23 13:13
银牌会员 Posts 646 Credits 1,604
I suggest posting the actual sample, and highlight the part you want to extract.
Floor10 dragonamd Posted 2008-08-23 13:21
中级用户 Posts 100 Credits 209
pusofalse
Do you have QQ? It's easier to talk on QQ. Once it's sorted out, I'll post it here
Floor11 pusofalse Posted 2008-08-23 13:24
银牌会员 Posts 646 Credits 1,604
- -||||Post it here so it can be solved
Floor12 HAT Posted 2008-08-23 13:29
版主 Posts 5,017 Credits 9,023
Is the text content highly confidential or something? Why are you so reluctant to post it?
Floor13 dragonamd Posted 2008-08-23 13:33
中级用户 Posts 100 Credits 209
R02 u70.843 i-19.91 5-10.17 I5.641
U71.796 B-18.487 5-8.11 I4.556
G75.13 H-10.666 5-9.16 I-9.209
F75.13 5-7.27 H-10.666 I-9.209

In the section above, the number 10.17 after 5- is the largest, so it should display 5-10.17

What HAT said is a bit too serious. The text isn't confidential, it's just that I don't know how to mark highlights on the forum, so I'm doing it little by little, hehe

[ Last edited by dragonamd on 2008-8-23 at 01:37 PM ]
Floor14 pusofalse Posted 2008-08-23 13:54
银牌会员 Posts 646 Credits 1,604
Floor15 slore Posted 2008-08-23 14:12
铂金会员 Posts 2,478 Credits 5,212
@echo off&Setlocal Enabledelayedexpansion
Set MV=0
for /f "delims=" %%i in (T.txt) do (
Set L=%%i
Set L=!L:5-=轩!
Call :MaxValue "!L!"
)
pause>nul
exit /b

:MaxValue
Set L=%1
for /f "tokens=2 delims=轩" %%i in (%L%) do (
for /f "delims= " %%j in ("%%i") do (
rem Because floating-point arithmetic is not supported, using GTR did not give the correct result, change it yourself.
rem If %%j GTR !MV! Set MV=%%j
echo %%j
)
)
1 2  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023