|
wudixin96
银牌会员
    
积分 1928
发帖 931
注册 2007-1-6
状态 离线
|
『第 16 楼』:
使用 LLM 解释/回答一下
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 ]
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 ...
Using FOR, it seems that using WHILE would be better.
Loop using the op.atendofstream property.
Didn't look closely at slore's reply. Just posting water. o(∩_∩)o... Haha
Last edited by wudixin96 on 2007-5-12 at 05:38 PM ]
|
|
2007-5-12 17:34 |
|
|
zhoushijay
高级用户
    Autowalk
积分 845
发帖 375
注册 2007-3-3
状态 离线
|
『第 17 楼』:
使用 LLM 解释/回答一下
经过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 ]
After the suggestion from floor 13, I made a little modification. But I still think the dictionary is more convenient. The main reason for the last mistake was the algorithm error in extracting the largest number from the set. Now it has been corrected and tested.
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> |
|
2007-5-13 10:56 |
|
|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第 18 楼』:
使用 LLM 解释/回答一下
t=mid(ln,17,2)
t=mid(ln,17,3)
?这样T不是只有一个?
t = mid(ln, 17, 2)
t = mid(ln, 17, 3)
? Then T is only one?
|
|
2007-5-13 11:19 |
|
|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第 19 楼』:
使用 LLM 解释/回答一下
还好他后面有空格
XX C
XXX C
你取3位。。。“XX ”或者“XXX”经INT后就是XX 和 XXX
Fortunately, there are spaces after it.
XX C
XXX C
You take 3 digits... "XX " or "XXX" after INT becomes XX and XXX.
|
|
2007-5-13 11:24 |
|
|
zhoushijay
高级用户
    Autowalk
积分 845
发帖 375
注册 2007-3-3
状态 离线
|
『第 20 楼』:
使用 LLM 解释/回答一下
那直接取3位好了
Then just take 3 digits.
|

你好,脚本专家!
<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> |
|
2007-5-13 12:18 |
|
|
sonicandy
中级用户
  
积分 273
发帖 91
注册 2007-5-7
状态 离线
|
   『第 21 楼』:
使用 LLM 解释/回答一下
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
Option Explicit 'Strict syntax
Dim reg, matches, match, file, max, flag, submatch, fso, temp
Set fso = CreateObject("scripting.filesystemobject")'Create FSO object
Set reg = new regexp 'Create regular expression object
reg.global = True 'Global search
reg.ignorecase = True 'Ignore case
reg.pattern = "CT : *(+) +C" 'Matching pattern string (regular expression)
flag = False 'Mark whether it is the first loop
Set file = fso.opentextfile("1.txt",1)
If Not file.atendofstream Then 'File is not empty
Set matches = reg.execute(file.readall()) 'Execute search
For Each match In matches 'Iterate all matches
For Each submatch In match.submatches 'Iterate matching sub-items (content in parentheses in pattern string)
temp = Int(submatch) 'Transform into positive number
Next
If flag=False Then 'First time direct assignment
max = temp
flag = True
ElseIf max<temp Then 'Comparison assignment later
max = temp
End if
Next
End If
If max>45 And max<90 Then
MsgBox "OK"
Else
MsgBox "NG"
End If
'Release object
Set reg = Nothing
Set fso = Nothing
|
|
2007-5-13 18:54 |
|