Jump to content

Recommended Posts

Posted (edited)

Hi sir,

I have below code but I found the "Or" doesn't work for me, for example, when the "$v2 = 3" then the script will still execute the code belong to "If $v2 = 1 Or 2 Then", please advise what is the problem, thanks.

If $v2 = 1 Or 2 Or 3 Or 4 Then
            GUICtrlSetData($msgbox, "Logging SUT power status, please wait.....")
            FileWrite($sFile2, "====================" & $i & " cycle run====================" & @CRLF)
            FileWrite($sFile2, @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & @CRLF)
            If $v2 = 2 Or 4 Then
                FileWrite($sFile3, "====================" & $i & " cycle run====================" & @CRLF)
                FileWrite($sFile3, @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & @CRLF)
            EndIf
            If $v2 = 1 Or 2 Then
                FileWrite($sFile2,"Status should be POWER OFF" & @CRLF)
                If $v2 = 2 Then
                    FileWrite($sFile3,"Status should be POWER OFF" & @CRLF)
                EndIf
            ElseIf $v2 = 3 Or 4 Then
                FileWrite($sFile2,"Status should be POWER ON" & @CRLF)
                If $v2 = 4 Then
                    FileWrite($sFile3,"Status should be POWER ON" & @CRLF)
                EndIf
            EndIf
            RunWait(@ComSpec & " /c" & "ipmitool.exe " & "-H" & " " & $CmdLine[2] & " " & "-U" & " " & $CmdLine[3] & " " & "-P" & " " & $CmdLine[4] & " " & "power" & " " & "status" & " " & ">>" & " " & $sFile2)
            FileWrite($sFile2,@CRLF)

Jacky

Edited by jackylee0908
Posted
2 minutes ago, Subz said:

You would need to specify $v2 = 1 or $v2 = 2... etc.. otherwise you can use switch

Hi @Subz,

:sweating:

OK I got the point now, I will try to fix and to see if the problem can be solved or not, will update later.

Posted

Example of switch untested.

Switch $v2
    Case 1, 2, 3, 4
        GUICtrlSetData($msgbox, "Logging SUT power status, please wait.....")
        FileWrite($sFile2, "====================" & $i & " cycle run====================" & @CRLF)
        FileWrite($sFile2, @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & @CRLF)
        If $v2 = 2 Or $v2 = 4 Then
            FileWrite($sFile3, "====================" & $i & " cycle run====================" & @CRLF)
            FileWrite($sFile3, @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & @CRLF)
        EndIf
        Switch $v2
            Case 1, 2
            FileWrite($sFile2,"Status should be POWER OFF" & @CRLF)
            If $v2 = 2 Then FileWrite($sFile3,"Status should be POWER OFF" & @CRLF)
            Case 3, 4
                FileWrite($sFile2,"Status should be POWER ON" & @CRLF)
                If $v2 = 4 Then FileWrite($sFile3,"Status should be POWER ON" & @CRLF)
        EndSwitch
        RunWait(@ComSpec & " /c ipmitool.exe -H " & $CmdLine[2] & " -U " & $CmdLine[3] & " -P " & $CmdLine[4] & " power status >> " & $sFile2)
        FileWrite($sFile2,@CRLF)
EndSwitch

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...