Page 1 of 1
Responsive Forms
Posted: Tue Oct 09, 2018 6:24 am
by Genx13
I'm having trouble wrapping my head around the responsive forms with the examples from the articles below. Does anyone have a simple form that copies files or something they could share using this method. I really think I just need to see an example of a working script that I can dissect.
https://www.sapien.com/blog/2011/07/15/primalforms-2011-creating-responsive-loops
https://info.sapien.com/index.php/guis/gui-advanced-tips/creating-responsive-loops
Re: Responsive Forms
Posted: Tue Oct 09, 2018 8:46 am
by jvierra
The "Start Job" custom control set is also an example. Just place it on a new form and run it. Look at the code and notice what it is doing.
Re: Responsive Forms
Posted: Thu Oct 11, 2018 12:38 pm
by Genx13
So I looked again at the "Button-Start Job" code along with a longer look at the Creating Responsive Forms and Responsive Loops.
I think It's starting to sink in a bit I'm still not getting something. I used your "Demo-JobChildForm" as a template, I have a main form with one button that opens the child form below. Using the code from the "Creating Responsive Forms" I can get the ping to run and the progress bar to fill. I edited that to try doing a copy-Item but I can't figure out how to get the progress bar to work with the $count variable.
I'm sure I'm doing something wrong i just can't see where. My best guess is I'm doing something wrong with the $UpdateScript code. Also the files do copy the bar just doesn't reflect that.
param
(
$JobName = 'MyJob'
)
$JobScript =
{
$Source = 'C:\Users\tuser\Desktop'
$Destination = 'C:\Users\tuser\Documents\TestCopy'
[int]$Count = $Source.count
for ($i = 0; $i -lt "$($Count)"; $i++)
{
#Do some work
Copy-Item -Path $Source -Destination $Destination -Recurse
#Start-Sleep -Milliseconds 100
#Output Progress
$i + 1
}
}
$UpdateScript =
{
Param ($Job)
$results = Receive-Job -Job $Job | Select-Object -Last 1
if ($results -is [int])
{
$PBar_Copy.Value = $results
}
}
$CompletedScript =
{
Param ($Job, $Count)
$PBar_Copy.Value = $Count
}
$formChildForm_Load={
#TODO: Place custom script here
Add-JobTracker -Name $JobName -JobScript $jobscript -UpdateScript $updatescript -CompletedScript $completedscript
}
Re: Responsive Forms
Posted: Thu Oct 11, 2018 12:50 pm
by jvierra
Copy-Item has no output and will block the loop until it is done. The progress bar will not work here.
Re: Responsive Forms
Posted: Thu Oct 11, 2018 12:57 pm
by Genx13
Is there any other way to show the progress during a file copy? Would a Marquee Progress bar work?
Do you have any recommendations for show progress on a file copy, that could show a percentage done or anything?
Would Copy-WithProgress work better?
Re: Responsive Forms
Posted: Thu Oct 11, 2018 1:31 pm
by jvierra
No. There is no progress for any blocking command.