中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

中国DOS联盟论坛
现在时间是 2026-07-14 23:31
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » 如果將1文本的1組溫度記錄值的最大值找出,并加以判斷 查看 2,451 回复 20
16 发表于 2007-05-12 17:34 ·  中国 浙江 杭州 联通
银牌会员
★★★
积分 1,928
发帖 931
注册 2007-01-06 11:46
19年会员
UID 75624
性别 男
状态 离线
Originally posted by zhoushijay at 2007-5-12 04:26 PM:
set fso=createobject("scripting.filesystemobject")
set op=fso.opentextfile("1.txt",1)
set d=createobject("scripting.dictionary")
on error resume next
for i=1 to 10 ...


用FOR,好像用while好点。
用op.atendofstream属性循环。

没仔细 看slore的回复。灌水了 。o(∩_∩)o...哈哈

[ Last edited by wudixin96 on 2007-5-12 at 05:38 PM ]
17 发表于 2007-05-13 10:56 ·  中国 新疆 乌鲁木齐 电信
高级用户
★★★
Autowalk
积分 845
发帖 375
注册 2007-03-03 01:58
19年会员
UID 80606
性别 男
状态 离线
经过13楼建议,我作了一点修改,不过我还是认为dictionary比较方便,上次错误的主要原因是提取集合中的最大数的算法错误,现在已经改正,并且测试过了.

set fso=createobject("scripting.filesystemobject")
set op=fso.opentextfile("1.txt",1)
set d=createobject("scripting.dictionary")
i=1
do until op.atendofstream=true
ln=op.readline
t=mid(ln,17,3)
on error resume next
t=int(t)
if err=0 then
d.add i,t
end if
i=i+1
loop
mx=0
for each i in d
if d(i)>mx then
mx=d(i)
end if
next

if mx>45 and mx<90 then
msgbox("Temperature is OK"&chr(10)&"The hotest is "&mx&"C")
else
msgbox("Temperature is NG"&chr(10)&"The hotest is "&mx&"C")
end if

[ Last edited by zhoushijay on 2007-5-13 at 12:19 PM ]
你好,脚本专家!
<a target=blank href=tencent://message/?uin=29654761&Site=www.111.com&Menu=yes><img border="0" SRC=http://wpa.qq.com/pa?p=1:29654761:5 alt="点击这里给我发消息"></a>
18 发表于 2007-05-13 11:19 ·  中国 陕西 西安 电信
铂金会员
★★★★
积分 5,212
发帖 2,478
注册 2007-02-08 23:39
19年会员
UID 79003
性别 男
状态 离线
t=mid(ln,17,2)

t=mid(ln,17,3)
?这样T不是只有一个?
19 发表于 2007-05-13 11:24 ·  中国 陕西 西安 电信
铂金会员
★★★★
积分 5,212
发帖 2,478
注册 2007-02-08 23:39
19年会员
UID 79003
性别 男
状态 离线
还好他后面有空格

XX C
XXX C

你取3位。。。“XX ”或者“XXX”经INT后就是XX 和 XXX
20 发表于 2007-05-13 12:18 ·  中国 新疆 乌鲁木齐 电信
高级用户
★★★
Autowalk
积分 845
发帖 375
注册 2007-03-03 01:58
19年会员
UID 80606
性别 男
状态 离线
那直接取3位好了
你好,脚本专家!
<a target=blank href=tencent://message/?uin=29654761&Site=www.111.com&Menu=yes><img border="0" SRC=http://wpa.qq.com/pa?p=1:29654761:5 alt="点击这里给我发消息"></a>
21 发表于 2007-05-13 18:54 ·  中国 北京 利达宽带
中级用户
★★
积分 273
发帖 91
注册 2007-05-07 18:12
19年会员
UID 87770
性别 男
状态 离线
Option Explicit '语法严格
Dim reg,matches,match,file,max,flag,submatch,fso,temp

Set fso = CreateObject("scripting.filesystemobject")'创建FSO对象
Set reg = new regexp '创建正则对象

reg.global = True '全局搜索
reg.ignorecase = True '忽略大小写
reg.pattern = "CT : *([0-9\-]+) +C" '匹配模式字符串(正则表达式)
flag = False '标记是否为第一次循环
Set file = fso.opentextfile("1.txt",1)

If Not file.atendofstream Then '文件不为空
Set matches = reg.execute(file.readall()) '执行搜索
For Each match In matches '遍历所有匹配项
For Each submatch In match.submatches '遍历匹配子项(模式字符串中括号里的内容)
temp = Int(submatch) '转化为正数
Next
If flag=False Then '第一次直接赋值
max = temp
flag = True
ElseIf max<temp Then '以后比较赋值
max = temp
End if
Next
End If

If max>45 And max<90 Then
MsgBox "OK"
Else
MsgBox "NG"
End If

'释放对象
Set reg = Nothing
Set fso = Nothing
本帖最近评分记录 (共 1 条) 点击查看详情
评分人分数时间
baomaboy +11 2007-05-13 19:02
论坛跳转: