qq82015930 发表于 2013-1-24 12:30:59

求优化【以解决】

本帖最后由 qq82015930 于 2013-1-25 19:49 编辑

$hmdpaht = IniRead(@ScriptDir & "\config.sec","ph","path","")
$okhmdpaht = FileExists($hmdpaht) ;查看文件是否存在
If $okhmdpaht = 0 Then
        MsgBox(262208,"","hmd哭不存在,检测配置")
Else
       
;MsgBox(262208,$hmdpaht,"")
$hmd11 = IniRead($hmdpaht,"hmd","hmd11","")
$hmd12 = IniRead($hmdpaht,"hmd","hmd12","")
$hmd13 = IniRead($hmdpaht,"hmd","hmd13","")

$hmd21 = IniRead($hmdpaht,"hmd","hmd21","")
$hmd22 = IniRead($hmdpaht,"hmd","hmd22","")
$hmd23 = IniRead($hmdpaht,"hmd","hmd23","")

$hmd31 = IniRead($hmdpaht,"hmd","hmd31","")
$hmd32 = IniRead($hmdpaht,"hmd","hmd32","")
$hmd33 = IniRead($hmdpaht,"hmd","hmd33","")

$hmd41 = IniRead($hmdpaht,"hmd","hmd41","")
$hmd42 = IniRead($hmdpaht,"hmd","hmd42","")
$hmd43 = IniRead($hmdpaht,"hmd","hmd43","")

$hmd51 = IniRead($hmdpaht,"hmd","hmd51","")
$hmd52 = IniRead($hmdpaht,"hmd","hmd52","")
$hmd53 = IniRead($hmdpaht,"hmd","hmd53","")

$hmd61 = IniRead($hmdpaht,"hmd","hmd61","")
$hmd62 = IniRead($hmdpaht,"hmd","hmd62","")
$hmd63 = IniRead($hmdpaht,"hmd","hmd63","")

$Gethmd = "hmd123456"

If $Gethmd = $hmd11 Then
        _xt()
ElseIf $Gethmd = $hmd12 Then
        _xt()
ElseIf $Gethmd = $hmd13 Then
        _xt()
ElseIf $Gethmd = $hmd21 Then
        _xt()
ElseIf $Gethmd = $hmd22 Then
        _xt()
ElseIf $Gethmd = $hmd23 Then
        _xt()
ElseIf $Gethmd = $hmd31 Then
        _xt()
ElseIf $Gethmd = $hmd32 Then
        _xt()
ElseIf $Gethmd = $hmd33 Then
        _xt()
ElseIf $Gethmd = $hmd41 Then
        _xt()
ElseIf $Gethmd = $hmd42 Then
        _xt()
ElseIf $Gethmd = $hmd43 Then
        _xt()
ElseIf $Gethmd = $hmd51 Then
        _xt()
ElseIf $Gethmd = $hmd52 Then
        _xt()
ElseIf $Gethmd = $hmd53 Then
        _xt()
ElseIf $Gethmd = $hmd61 Then
        _xt()
ElseIf $Gethmd = $hmd62 Then
        _xt()
ElseIf $Gethmd = $hmd63 Then
        _xt()
Else
        MsgBox(262208,"","没找到")
EndIf

EndIf

Func _xt()
        MsgBox(262208,"提示","有相同hmd")
EndFunc谢谢,两位大侠的指点.

netegg 发表于 2013-1-24 12:37:23

本帖最后由 netegg 于 2013-1-24 12:39 编辑


$dqhmd = "hmd123456"
local $Gethmd
        Switch $Gethmd
                Case $hmd11 To $hmd63
                        _xt()
                Case Else
                        MsgBox(262208, "", "没找到")
        EndSwitch

EndIf

Func _xt()
        MsgBox(262208, "提示", "有相同hmd")
EndFunc   ;==>_xt
不过没看明白,这个$Gethmd到底是什么,从什么地方冒出来的

qq82015930 发表于 2013-1-24 12:58:53

回复 2# netegg


    $Gethmd   $dqhmd   写错啦

netegg 发表于 2013-1-24 13:29:51

本帖最后由 netegg 于 2013-1-24 13:37 编辑


      Switch "hmd123456"
                Case $hmd11, $hmd12, $hmd13, $hmd21,$hmd22, $hmd23,$hmd31, $hmd32, $hmd33, $hmd41,$hmd42, $hmd43,$hmd51, $hmd52, $hmd53, $hmd61,$hmd62, $hmd63
                        _xt()
                Case Else
                        MsgBox(262208, "", "没找到")
      EndSwitch

EndIf

Func _xt()
      MsgBox(262208, "提示", "有相同hmd")
EndFunc   ;==>_xt

haijie1223 发表于 2013-1-24 13:33:33

本帖最后由 haijie1223 于 2013-1-24 14:11 编辑

还是用数组吧
Dim $hmd
$hmdpaht = IniRead(@ScriptDir & "\config.sec", "ph", "path", "")
$Gethmd = "hmd123456"

If FileExists($hmdpaht) Then
        For $i = 1 To 18
                $hmd[$i] = IniRead($hmdpaht, "hmd", "hmd" & $i, "")
                If $Gethmd = $hmd[$i] Then MsgBox(262208, "提示", "有相同hmd")
        Next
Else
        MsgBox(262208, "", "hmd哭不存在,检测配置")
EndIf

netegg 发表于 2013-1-24 13:38:29

本帖最后由 netegg 于 2013-1-24 13:39 编辑

回复 5# haijie1223
这么写我试了试,好像不行,不过问题应该好找,可能是没赋值的关系

haijie1223 发表于 2013-1-24 14:20:18

回复 6# netegg


    我改了一下,还是用数组比较方便

netegg 发表于 2013-1-24 14:36:58

回复 7# haijie1223
那么写的话,一样要用索引切换条件,不用循环,要不有一堆是废的

netegg 发表于 2013-1-24 14:46:24

本帖最后由 netegg 于 2013-1-24 14:51 编辑

算了,整个大概可以的完整的吧$hmdpaht = IniRead(@ScriptDir & "\config.sec", "ph", "path", "")
If FileExists($hmdpaht) Then
    For $i = 1 To 6
      For $j = 1 To 3
            If StringInStr("hmd123456", IniRead($hmdpaht, "hmd", "hmd" & $i & $j, "") Then
                xt()
            Else
                MsgBox(262208, "", "没找到")
            EndIf
      Next
    Next
Else
    MsgBox(262208, "", "没找到")
EndIf

Func _xt()
        MsgBox(262208, "提示", "有相同hmd")
EndFunc   ;==>_xt
页: [1]
查看完整版本: 求优化【以解决】