Hi there
I've read the page on "Responsive forms" quite a few times and i'll be honest I'm having a nightmare figuring out something I believe should be quite simple to understand.
I've created a UI (see attachment). Its pretty basic. it contains the following as you'll see:
* Two checkboxes
* Textbox
* Various buttons
* Listbox
* Richtextbox (for outputting purposes)
* Progressbar (using the 'progress bar - responsive loop' control set)
The listbox accepts CSV input as well as a list from TXT file. These can either be imported (using the button) or dragged and dropped on the box. Items can also be added via the TEXT box and pressing the corresponding button. The LISTBOX also checks to see if value already exists and if it does it wont add it.
'Clear Select' removes selected items from the LISTBOX and 'Clear All' Removes all items.
So onto the issues I'm facing/need help with.
When I click the 'Start Process' button it needs to one of four things depending on the following:
1. if($checkbox1.checkstate -eq unchecked -and $checkbox2.checkstate -eq unchecked){Do something with multiple if statements}
2. if($checkbox1.checkstate -eq checked -and $checkbox2.checkstate -eq checked){Do something with multiple if statements}
3. if($checkbox1.checkstate -eq checked -and $checkbox2.checkstate -eq unchecked){Do something with multiple if statements}
4. if($checkbox1.checkstate -eq unchecked -and $checkbox2.checkstate -eq checked){Do something with multiple if statements}
what ever process is relevant I then need it to loop through the items within the listbox and output certain things to the Richtextbox such as:
listbox item processing
Error doing something
Something completed
Rinse and repeat
So heres issue one - I cant seem to get it to stop looping though the Listbox once its completed? instead it just continuely cycles while the progress steps up to full.
Issue number two, below is obviously the code for the progressbar and my issue is where or how do I put all the above to make it work. As stated right back at the start I'm sure this is me being purely stupid and probably overthinking it but having spent a couple of days reading and trying various things I'm now at your hopefully helpful mercy.
$buttonStartProcess_Click={
#Init CancelLoop
$script:CancelLoop = $false
$buttonCancelProcess.Enabled = $true
#Disable the button so we don't trigger it again
$this.Enabled = $false
#Reset the Progress Bar
$progressbar1.Value = 0
for($i = 0; $i -lt $progressbar1.Maximum; $i++)
{
#----------------------------------------
#Place custom script here
sleep -Milliseconds 200
#----------------------------------------
#process the pending message
[System.Windows.Forms.Application]::DoEvents()
if($script:CancelLoop -eq $true)
{
#Clear the progress bar
$progressbar1.Value = 0
#Exit the loop
break;
}
#Step the progress bar
$progressbar1.PerformStep()
}
#Enable the button so we can click it again
$this.Enabled = $true
$buttonCancelProcess.Enabled = $false
}
Responsive loop progress bar - sending me loopy
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Responsive loop progress bar - sending me loopy
- Attachments
-
- form_UI.PNG (11.09 KiB) Viewed 2563 times
Re: Responsive loop progress bar - sending me loopy
If you keep clearing the progress bar the loop will never exit.
The rules of responsive forms say avoid processing in a loop while in an event.
If you have a job with multiple steps then run it as a job and use the JobTracker to manage the job.
The rules of responsive forms say avoid processing in a loop while in an event.
If you have a job with multiple steps then run it as a job and use the JobTracker to manage the job.
Re: Responsive loop progress bar - sending me loopy
had a feeling you were going to say about the job tracker............something else I cant for some reason get my head around...i'll have a another good read up and see what I can do
- MarvelManiac
- Posts: 63
- Last visit: Thu Sep 13, 2018 3:40 pm
Re: Responsive loop progress bar - sending me loopy
Here is a breakdown for you that should help at least start wrapping your head around Jobs. It took me over a year and I'm still probably not doing it the most efficient way.