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-08-09 13:21
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Been racking my brains, finding the largest number in Notepad View 1,944 Replies 17
Original Poster Posted 2008-08-23 02:22 ·  中国 江苏 苏州 太仓市 电信
中级用户
★★
Credits 209
Posts 100
Joined 2008-08-01 02:53
18-year member
UID 122532
Gender Male
Status Offline
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 ]
Floor 2 Posted 2008-08-23 11:26 ·  中国 上海 电信
银牌会员
★★★
永远的菜鸟
Credits 1,335
Posts 574
Joined 2007-11-27 12:50
18-year member
UID 103929
Gender Male
From 广西
Status Offline
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



@echo off
for /f "tokens=1,2 delims=-" %%a in (a.txt) do (
if "%%a"=="5" (call set str=%%str%% %%b)
)
for %%a in (%str%) do (
set n=1
for %%b in (%str%) do (if %%a gtr %%b set /a n+=1)
call set _%%n%%=%%a
)
call echo 5-%%_%n%%%
pause
Floor 3 Posted 2008-08-23 11:32 ·  中国 山东 淄博 联通
银牌会员
★★★
Credits 1,604
Posts 646
Joined 2008-04-13 23:39
18-year member
UID 115804
Gender Male
Status Offline
心绪平和,眼藏静谧,无比安稳的火... Purification of soul...Just a false...^_^
Floor 4 Posted 2008-08-23 12:39 ·  中国 江苏 苏州 太仓市 电信
中级用户
★★
Credits 209
Posts 100
Joined 2008-08-01 02:53
18-year member
UID 122532
Gender Male
Status Offline
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
Floor 5 Posted 2008-08-23 12:43 ·  中国 山东 淄博 联通
银牌会员
★★★
Credits 1,604
Posts 646
Joined 2008-04-13 23:39
18-year member
UID 115804
Gender Male
Status Offline
You mean there are two columns in one line?
心绪平和,眼藏静谧,无比安稳的火... Purification of soul...Just a false...^_^
Floor 6 Posted 2008-08-23 12:50 ·  中国 江苏 苏州 太仓市 电信
中级用户
★★
Credits 209
Posts 100
Joined 2008-08-01 02:53
18-year member
UID 122532
Gender Male
Status Offline
Many columns, at least around 7-8 columns I guess
Floor 7 Posted 2008-08-23 12:58 ·  中国 山东 淄博 联通
银牌会员
★★★
Credits 1,604
Posts 646
Joined 2008-04-13 23:39
18-year member
UID 115804
Gender Male
Status Offline
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?
心绪平和,眼藏静谧,无比安稳的火... Purification of soul...Just a false...^_^
Floor 8 Posted 2008-08-23 13:09 ·  中国 江苏 苏州 太仓市 电信
中级用户
★★
Credits 209
Posts 100
Joined 2008-08-01 02:53
18-year member
UID 122532
Gender Male
Status Offline
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-
Floor 9 Posted 2008-08-23 13:13 ·  中国 山东 淄博 联通
银牌会员
★★★
Credits 1,604
Posts 646
Joined 2008-04-13 23:39
18-year member
UID 115804
Gender Male
Status Offline
I suggest posting the actual sample, and highlight the part you want to extract.
心绪平和,眼藏静谧,无比安稳的火... Purification of soul...Just a false...^_^
Floor 10 Posted 2008-08-23 13:21 ·  中国 江苏 苏州 太仓市 电信
中级用户
★★
Credits 209
Posts 100
Joined 2008-08-01 02:53
18-year member
UID 122532
Gender Male
Status Offline
pusofalse
Do you have QQ? It's easier to talk on QQ. Once it's sorted out, I'll post it here
Floor 11 Posted 2008-08-23 13:24 ·  中国 山东 淄博 联通
银牌会员
★★★
Credits 1,604
Posts 646
Joined 2008-04-13 23:39
18-year member
UID 115804
Gender Male
Status Offline
- -||||Post it here so it can be solved
心绪平和,眼藏静谧,无比安稳的火... Purification of soul...Just a false...^_^
Floor 12 Posted 2008-08-23 13:29 ·  中国 重庆 九龙坡区 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Is the text content highly confidential or something? Why are you so reluctant to post it?
Floor 13 Posted 2008-08-23 13:33 ·  中国 江苏 苏州 太仓市 电信
中级用户
★★
Credits 209
Posts 100
Joined 2008-08-01 02:53
18-year member
UID 122532
Gender Male
Status Offline
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 ]
Floor 14 Posted 2008-08-23 13:54 ·  中国 山东 淄博 联通
银牌会员
★★★
Credits 1,604
Posts 646
Joined 2008-04-13 23:39
18-year member
UID 115804
Gender Male
Status Offline
心绪平和,眼藏静谧,无比安稳的火... Purification of soul...Just a false...^_^
Floor 15 Posted 2008-08-23 14:12 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
@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
)
)
S smile 微笑,L love 爱,O optimism 乐观,R relax 放松,E enthusiasm 热情...Slore
Forum Jump: