Razor Posted September 27, 2005 Posted September 27, 2005 Hi, I wrote this little script: While 1 If StringInStr ($manstr, "Dell") Then $pcman = "Dell" ExitLoop EndIf If StringInStr ($manstr, "Compaq") Then $pcman = "Compaq" ExitLoop EndIf If StringInStr ($manstr, "IBM") Then $pcman = "IBM" ExitLoop EndIf Wend It works, but if $manstr is something else, the script just pegs the processor (infinite loop), how do fix the above code to Exit if $manstr isn't one of the above 3?
Wb-FreeKill Posted September 27, 2005 Posted September 27, 2005 Something like: While 1 If StringInStr ($manstr, "Dell") Then $pcman = "Dell" ExitLoop EndIf If StringInStr ($manstr, "Compaq") Then $pcman = "Compaq" ExitLoop EndIf If StringInStr ($manstr, "IBM") Then $pcman = "IBM" ExitLoop EndIf If NOT StringInStr ($manstr, "Dell") Or StringInStr ($manstr, "Compaq") Or StringInStr ($manstr, "IBM") Then Exit Wend
MrSpacely Posted September 27, 2005 Posted September 27, 2005 (edited) Why use a while loop then it never loops. I stops after first run always useless to run a while loop then If you constantly want to check While 1 Select Case $manstr= "Dell" $pcman = "Dell" exitloop Case $manstr= "Compaq" $pcman = "Compaq" exitloop Case $manstr= "IBM" $pcman = "IBM" exitloop Case Else sleep(250) EndSelect Wend Here the loop does loop and checks every 4the of a second wich doesn't suck up much cpu Edited September 27, 2005 by MrSpacely
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