![]() |
中国DOS联盟-- 联合DOS 推动DOS 发展DOS --联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum |
| 游客 | 登录 | 注册 | 会员 | 搜索 | 中国DOS联盟 |
|
中国DOS联盟论坛 现在时间是 2026-08-29 08:53 |
共 47,816 主题排行 / 349,916 发帖 / 今日 0 篇 / 48,265 会员排行 |
| DOS批处理 & 脚本技术(批处理室) » 如果將1文本的1組溫度記錄值的最大值找出,并加以判斷 |
| 可打印版本 2,699 / 20 |
| 第16楼 wudixin96 | 发表于 2007-05-12 17:34 |
| 银牌会员 发帖 931 积分 1,928 | |
Originally posted by zhoushijay at 2007-5-12 04:26 PM: 用FOR,好像用while好点。 用op.atendofstream属性循环。 没仔细 看slore的回复。灌水了 。o(∩_∩)o...哈哈 [ Last edited by wudixin96 on 2007-5-12 at 05:38 PM ] |
|
| 第17楼 zhoushijay | 发表于 2007-05-13 10:56 |
| 高级用户 发帖 375 积分 845 | |
|
经过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 ] |
|
| 第18楼 slore | 发表于 2007-05-13 11:19 |
| 铂金会员 发帖 2,478 积分 5,212 | |
|
t=mid(ln,17,2)
t=mid(ln,17,3) ?这样T不是只有一个? |
|
| 第19楼 slore | 发表于 2007-05-13 11:24 |
| 铂金会员 发帖 2,478 积分 5,212 | |
|
还好他后面有空格
XX C XXX C 你取3位。。。“XX ”或者“XXX”经INT后就是XX 和 XXX |
|
| 第20楼 zhoushijay | 发表于 2007-05-13 12:18 |
| 高级用户 发帖 375 积分 845 | |
|
那直接取3位好了
|
|
| 第21楼 sonicandy | 发表于 2007-05-13 18:54 |
| 中级用户 发帖 91 积分 273 | |
|
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 2 |
|
[ 联系联盟系统管理团队 -
中国DOS联盟 -
标准版 ] Sponsored by ifanr Inc | © 2001–2023 |