jackylee0908 Posted January 10, 2019 Posted January 10, 2019 (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 January 10, 2019 by jackylee0908
Subz Posted January 10, 2019 Posted January 10, 2019 You would need to specify $v2 = 1 or $v2 = 2... etc.. otherwise you can use switch
jackylee0908 Posted January 10, 2019 Author Posted January 10, 2019 2 minutes ago, Subz said: You would need to specify $v2 = 1 or $v2 = 2... etc.. otherwise you can use switch Hi @Subz, 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.
Subz Posted January 10, 2019 Posted January 10, 2019 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
jackylee0908 Posted January 10, 2019 Author Posted January 10, 2019 Hi @Subz, thanks so much, it worked for me, thank you.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now