DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Progress bar bug

Solved!
Go to solution

Hello, im using progress bar functions in Diadem and in some cases it works, but i got a script to filter all channels in group, so i got following code:

 

Call LoopInit()

code in cycle:

Call ChnCFCFiltCalc(....
Call LoopInc(iProgressBar/iProgressBarCount*100)
Call Pause(0.01)

code after cycle

Call LoopDeInit()

The progress bar display itself 1 one, and after its dissapears for the rest of the cycle. I think the function to filtrer channel is killing the progress bar, do u got the same behaviour?

// i know i can use ActiveX COM object to display different progress bar, i would like to use the internal one if its working

 

diademVersion.png

0 Kudos
Message 1 of 6
(3,325 Views)

Hello,

try to feed progress bar with integer values. Following code worked perfectly fine for me...

Dim iProgressBar, iProgressBarCount
iProgressBarCount=222

Call LoopInit() 'Opens session to Progress bar
For iProgressBar = 1 to iProgressBarCount

'Insert your code here

Call LoopInc(trunc(iProgressBar/iProgressBarCount*100)) 'Updates the Progress bar with value between 0 and 100
Call Pause(0.01)
Next
Call LoopDeInit 'Clear the Progress bar

Reagards,

Ondřej K.

CLA, CTA, CLED
0 Kudos
Message 2 of 6
(3,287 Views)

Hi Lukas,

 

Commands that generate new channels in the Data Portal usually highjack the Progress Bar.  In those cases I usually use a non-modal dialog with MsgBoxDisp(), like this:

Sub MsgUpdate(Msg)
'updates the message shown in the non-modal dialog every time the ID stopwatch reaches DispSecs
  Dim ID, DispSecs
  ID = 9
  DispSecs = 1.0
  IF Stopwatch(ID) > DispSecs THEN
    Call MsgBoxDisp(Msg, "MB_NOBUTTON", "MsgTypeNote", 0, 0, 1)
    Call StopWatchReset(ID)
  END IF
End Sub ' MsgUpdate()

If you still want to use the progress bar, don't introduce your own static pause, but rather poll to see if enough progress has happened to warrant a redraw, like this:

MsgBox "Click OK and watch the progress bar increment" '... much more quickly"
'This block of code is vastly more efficient
'The progress bar is only updated 100 times
Loops = 150
CountStep = 5 ' %
NextCount = CountStep
Call LoopInit()'Opens session to Progress bar
For i = 1 To Loops
  ' Start of your code (simulated here)
  StartTime = Timer
  Do
    EndTime = Timer
  Loop Until EndTime-StartTime > 0.05
  ' End of your code (simulated here)
  LoopCount = Fix(100*i/Loops)
  IF LoopCount >= NextCount THEN
    Call LoopInc(LoopCount) ' Updates the Progress bar with value between 0 and 100
    NextCount = NextCount + CountStep
  End If
Next
Call LoopDeInit 'Clear the Progress Bar

Brad Turpin

DIAdem Progress Support Engineer

National Instruments

0 Kudos
Message 3 of 6
(3,263 Views)

Hi,

thanks for reply, your code works fine and i got a slow progress bar, but if i change the code to put a filtering function, the progress bar dont show at all

 

MsgBox "Click OK and watch the progress bar increment" '... much more quickly"
'This block of code is vastly more efficient
'The progress bar is only updated 100 times
Loops = 150
CountStep = 5 ' %
NextCount = CountStep
Call LoopInit()'Opens session to Progress bar
For i = 1 To Loops
  ' Start of your code (simulated here)
    Call ChnCFCFiltCalc("", Data.Root.ActiveChannelGroup.Channels(i), Data.Root.ActiveChannelGroup.Channels(i), "CFC_180", 0, "EndPoints", 10)
  ' End of your code (simulated here)
  LoopCount = Fix(100*i/Loops)
  IF LoopCount >= NextCount THEN
    Call LoopInc(LoopCount) ' Updates the Progress bar with value between 0 and 100
    NextCount = NextCount + CountStep
  End If
Next
Call LoopDeInit 'Clear the Progress Bar
0 Kudos
Message 4 of 6
(3,214 Views)
Solution
Accepted by topic author Lukas_Doubek

Hi Lukas,

 

Most of the DIAdem ANLAYSIS functions invoke the DIAdem progress bar, so it's confusing to try to direct that same progress bar with VBScript calls when other VBScript calls (that run an ANALYSIS routine) also try to control that one progress bar.  My recommendation would be to use a non-modal dialog to display the sequencing of the different ANALYSIS function calls (across multiple channels, groups, or files), and let each ANALYSIS function automatically display its progress using the one DIAdem progress bar.

 

Brad Turpin

DIAdem  Product Support Engineer

National Instruments

0 Kudos
Message 5 of 6
(3,202 Views)

Hi Lukas,

 

This is my preferred method to use the non-modal nature of the MsgBoxDisp() command.  You could also create your own SUDialog and call it non-modally, but this is usually sufficient:

 

Sub MsgUpdate(Msg)
'updates the message shown in the non-modal dialog every time the ID stopwatch reaches DispSecs
  Dim ID, DispSecs
  ID = 9
  DispSecs = 1.0
  IF Stopwatch(ID) > DispSecs THEN
    Call MsgBoxDisp(Msg, "MB_NOBUTTON", "MsgTypeNote", 0, 0, 1)
    Call StopWatchReset(ID)
  END IF
End Sub ' MsgUpdate()

Brad Turpin

DIadem Product Support Engineer

National Instruments

0 Kudos
Message 6 of 6
(3,201 Views)