Sign in to follow this  
Followers 0
JayHawkfl

Stuck in while loop/breaks buttons

8 posts in this topic

#1 ·  Posted (edited)

I've been working on this project for a while now, I got the buttons working properly with Dany. (who I would like to thank again)

Now how ever the second part of my program will not let me exit the program and also breaks the buttons. I need a way to interupt that loop. I haven't worked with functions and that might be the way to go but I'm stuck at the moment. Even just a point towords working would be great. I made a note "This is where it starts" is the loop that is messing me up

EDIT: if you copy my code into editor the line number the loop starts at is 54

#include

#include

#include

#include

#include

#region ### START Koda GUI section ### Form=

$Form1 = GUICreate("FuturePOS Control Panel", 305, 205, 192, 114)

$TreeView1 = GUICtrlCreateTreeView(16, 16, 169, 169)

$Button1 = GUICtrlCreateButton("DB OFF", 208, 16, 75, 25)

$Button2 = GUICtrlCreateButton("DB ON", 208, 64, 75, 25)

$Button3 = GUICtrlCreateButton("RELOAD DB", 208, 112, 75, 25)

$Button4 = GUICtrlCreateButton("RELOAD CC", 208, 160, 75, 25)

GUISetState(@SW_SHOW)

#endregion ### END Koda GUI section ###



Local $ws[25]

Local $wsPing[25]

Local $i = 0

Local $WSName = 0

Local $WSIP = 0

Local $WSIPTest = 0

Local $tmp = 0

Local $Workstations = GUICtrlCreateTreeViewItem("Workstations", $TreeView1)

Local $Count = 0



While $i < 20



$i = $i + 1

$tmp = "WS" & $i

$ws[$i] = IniRead("C:FPOS5FPOS5 extrasworkstationlist.ini", "WORKSTATIONLIST", $tmp, "xxx")

If ($ws[$i] <> "") And ($ws[$i] <> "xxx") Then

$TotalWS = $i

$wsPing[$i] = Ping($ws[$i], 3)

EndIf

WEnd



$ws[$i] = IniRead("C:FPOS5FPOS5 extrasworkstationlist.ini", "WORKSTATIONLIST", $tmp, "xxx")

$i = 0



If 1 = 1 Then

If $Count = 0 Then

If $ws[$i] <> "" Or $ws[$i] <> "xxx" Then

Do

$i = $i + 1

$WSName = GUICtrlCreateTreeViewItem("Workstation" & $i, $Workstations)

$wsPing[$i] = Ping($ws[$i], 1)

If $wsPing[$i] <> 0 Then

$WSIP = GUICtrlCreateTreeViewItem($ws[$i], $WSName)

EndIf

_GUICtrlTreeView_Expand($treeView1,$Workstations)

Until $i = $TotalWS

EndIf

$Count = $Count + 1

While $Count > 0 ;;;;;This is where it starts

Sleep(10000)

_GUICtrlTreeView_Delete($TreeView1, $Workstations)

$i = 0

$WSName = 0

$WSIP = 0

$Workstations = GUICtrlCreateTreeViewItem("Workstations", $TreeView1)

If $ws[$i] <> "" Or $ws[$i] <> "xxx" Then

Do

$i = $i + 1

$WSName = GUICtrlCreateTreeViewItem("Workstation" & $i, $Workstations)

$wsPing[$i] = Ping($ws[$i], 1)

If $wsPing[$i] <> 0 Then

$WSIP = GUICtrlCreateTreeViewItem($ws[$i], $WSName)

EndIf

_GUICtrlTreeView_Expand($treeView1,$Workstations)

Until $i = $TotalWS

EndIf

WEnd

EndIf

EndIf

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $Button1

Run(@ComSpec & " /c " & 'dbsetup /stopall', "", @SW_HIDE)

Case $Button2

Run(@ComSpec & " /c " & 'dbsetup /startall', "", @SW_HIDE)

Case $Button3

Run(@ComSpec & " /c " & 'dbsetup /stopall', "", @SW_HIDE)

Run(@ComSpec & " /c " & 'dbsetup /startall', "", @SW_HIDE)

Case $Button4

Run(@ComSpec & " /c " & 'net stop fposcreditcard5', "", @SW_HIDE)

Run(@ComSpec & " /c " & 'net start fposcreditcard5', "", @SW_HIDE)

EndSwitch

WEnd
Edited by JayHawkfl

Thanks for your time

 

Share this post


Link to post
Share on other sites



JayHawkfl,

It does not look like you are never getting to your message loop. How do you want to exit the loop controlled by

While $Count > 0
???

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

well, when you run the program, it will refresh $TreeView1 but it runs that loop for ever.

I need the program to let me click my buttons, currently I can't even close the program. I have to go through task manager to close it.

Thanks up front for your time kylomas

Edited by JayHawkfl

Thanks for your time

 

Share this post


Link to post
Share on other sites
  • Could I use a TimerDiff() so that it only runs every ten seconds instead of running while count > 0
  • Count is always > 0 so it will always run but if it only runs once TimerDiff hits 10 seconds
  • I had tried to do it this way before but with no positive results I can take another crack at it as long as we think it's possible :huh2:

Thanks for your time

 

Share this post


Link to post
Share on other sites

The way you have this written, there's no way for it to exit the second while loop, which appears to me to be a duplicate of the first While loop. So, if it can't exit that loop, it will never get to the loop where you're trying to read the buttons. What exactly are you attempting to do with the 2 loops?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

I need to refresh my tree view every ten seconds


Thanks for your time

 

Share this post


Link to post
Share on other sites

You need to make it a function that you call every ten seconds, not a constant loop. Otherwise, you'll never get to the part of the script that checks the buttons. Look at Adlibregister for how to do that.

And a note, don't use Sleep to pause this type of script for more than a second or your script will be unresponsive, because it halts the script for as long as the sleep time is.

1 person likes this

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

You need to make it a function

I was hoping I wouldn't have to but your right, I'll have to do a little bit of rescripting but I don't think it will be tooooooo bad.

I also want to thank everyone for all there help with this project, I have been all over tis site looking at examples and posted a few times (like this one) getting this moving forward.

I am very grateful


Thanks for your time

 

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0