找回密码
 加入
搜索
查看: 4623|回复: 5

[AU3基础] 处理IniRead读取的结果,如何把空的去掉?

[复制链接]
发表于 2010-2-10 11:13:36 | 显示全部楼层 |阅读模式
$1=IniRead(@ScriptDir&"\ini.ini","1","1","")
$2=IniRead(@ScriptDir&"\ini.ini","1","2","")
$3=IniRead(@ScriptDir&"\ini.ini","1","3","")
$4=IniRead(@ScriptDir&"\ini.ini","2","1","")
$5=IniRead(@ScriptDir&"\ini.ini","2","2","")
$6=IniRead(@ScriptDir&"\ini.ini","2","3","")
MsgBox(0,"如何去掉空的数据?",$1&"/"&$2&"/"&$3&"/"&$4&"/"&$5&"/"&$6)

MsgBox(0,"去掉空的数据的效果:",$1&"/"&$2&"/"&$4&"/"&$6)
ini内容:

[1]
1=123
2=456
3=
[2]
1=789
2=
3=321
发表于 2010-2-10 11:32:53 | 显示全部楼层
读取数据后很简单的判断一下就行了。
$iSectionName = IniReadSectionNames("test.ini")
$temp2 = ""
$temp1 = ""
For $i=0 To $iSectionName[0]-1
        For $j=1 To 3
                $rStr = IniRead("test.ini",$iSectionName[$i+1],$j,"")
                If $rStr <> "" Then
                        $temp2 &= $rStr &@CRLF
                EndIf
                $temp1 &= $rStr &@CRLF
        Next
Next

MsgBox (0,"效果","如何去掉空的数据?"&@CRLF &$temp1&@CRLF&"去掉空的数据的效果:"&@CRLF&$temp2)

评分

参与人数 1金钱 +20 收起 理由
jinhao + 20 谢谢帮忙,问题解决了。

查看全部评分

 楼主| 发表于 2010-2-10 11:55:00 | 显示全部楼层
每锻数据要用"/"分开的啊
发表于 2010-2-10 11:59:16 | 显示全部楼层
回复 3# jinhao

你改一下分隔符就可以了
发表于 2010-2-10 12:04:33 | 显示全部楼层
帮你再改一改,用“/”分开
$iSectionName = IniReadSectionNames("test.ini")
$temp2 = ""
$temp1 = ""
For $i=0 To $iSectionName[0]-1
        For $j=1 To 3
                $rStr = IniRead("test.ini",$iSectionName[$i+1],$j,"")
                If $rStr <> "" Then
                        $temp2 &= $rStr &"/"
                EndIf
                $temp1 &= $rStr &"/"
        Next
Next
$temp1 = StringTrimRight($temp1,1)
$temp2 = StringTrimRight($temp2,1)
MsgBox (0,"效果","如何去掉空的数据?"&@CRLF &$temp1&@CRLF&@CRLF&"去掉空的数据的效果:"&@CRLF&$temp2)
发表于 2010-2-11 19:16:21 | 显示全部楼层
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-16 11:47 , Processed in 0.082685 second(s), 27 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表