From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Display progress bar while using Calculate function

Solved!
Go to solution

Hello,

 

For my project, I have to convert the raw values of a signal to physical values.

To do this, I'm using the "Calculate" function.

Because I have a lot of data, it takes time and the user doesn't know if it works or not.

 

The first thing I did, is to add Dialog.BeginWaitCursor and Dialog.EndWaitCursor that works well but is not sufficient.

To display activity, I would like to display a progress bar created before calling "Calculate" and stopped after that.

The progress bar doesn't need to display the real progress but only display a progress moving even if it starts again from zeor until the end of the calculation.

 

I read some information about progress on this forum but it was done on selfmade function and not calling DIAdem functions.

That's why it is not usefull for me.

 

I don't know how to do that using vbs.

Is it possible to create something like that ?

 

The best solution would be to get the progress of the "Calculate" function to know where it is but the function is not created to do this.

 

Thanks for any ideas,

Best Regards,

 

CFOE

0 Kudos
Message 1 of 10
(8,507 Views)

Hello cfoe:

 

Use an ActiveX control, this works pretty well and is easy to program it.

 

 

Progressbar.png

 

Here i send you a small function to set the value of the the bar between 0 - 100

 

' ProgressBarObject : object in the SUD dialog,
' nVal : value of the progress
Sub ProgBar ( ProgressBarObject , nVal)
  Dim objc   
  Set objc = ProgressBarObject.X
  objc.Enabled = True
  objc.Max = 100
  objc.Min = 0
  objc.Scrolling =1
  objc.Appearance =1
  objc.BorderStyle=1
  objc.OLEDropMode=1
  Dim j : j = nVal 
  objc.Value = j
  Pause (0.01)
  objc.Refresh
  Pause (0.01)
Next

 

Regards.

0 Kudos
Message 2 of 10
(8,481 Views)

Hi Guys,

 

Be forewarned, though, the trouble with using external COM objects or ActiveX controls is when you go to distribute your application to other computers.  Not all the target computers will necessarily have the required COM object or ActiveX control installed, and even if they do it could be the wrong version.  You usually end up needing an installer to automaticall install AND register the required external components, and that's extra work.  Sometime you do get lucky, though, and all the target computers really are the same in this regard 🙂

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 3 of 10
(8,469 Views)

Hi guys,

 

Thanks for the responses, in fact to sum up, we can say that there is no simple way to do this without adding or installing extra components.

 

CFOE

0 Kudos
Message 4 of 10
(8,446 Views)
Solution
Accepted by cfoe

Hey CFOE,

 

I asked R&D in parallel, because I thought I remembered seeing a continuous progress bar in DIAdem before, but I wasn't sure if that was something we could call with a VBScript command.  I just heard back that you can, and here it is...

 

Call AutoLoopInit
MsgBox "Ready to Stop the Progress Bar?"
Call LoopDeInit

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

Message 5 of 10
(8,436 Views)

Thank you Brad,

 

I use this function know and it helps me.

I didn't saw that because it was no so quite obvious.

 

Best Regards,

CFOE

Message 6 of 10
(8,415 Views)

Hello. 

 

I wanted to kindly ask you if there is any possibility to change the Activex Progress Bar Color.

 

Thank You for your help

 

Best Regards

0 Kudos
Message 7 of 10
(7,474 Views)

Hi marispaulies,

 

What do you mean by an "Activex Progress Bar"?  DIAdem doesn't install one that I know of, so I'm guessing you've picked an ActiveX control that is registered with your operating system.

 

You can typically set the ActiveX property "Foo" of an ActiveX control named "MyControl" in a SUDialog by the following syntax:

 

MyControl.X.Foo = NewValue

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

Message 8 of 10
(7,423 Views)

Hi Brad,

Using the example from the DIAdem help:

Dim intLoop
Call LoopInit()
For intLoop= 1 To 100
  Call LoopInc(intLoop)
  Call Pause(0.1)
Next
Call LoopDeInit()

 I did get a status bar to display in one of my scripts, but in another it popped up for a second and then disappeared. What could cause that?

 

The difference between the scripts is that one is looping through loaded data and the other (with the disappearing status bar) is looping through files which get loaded and removed on the fly. It also calls Portal.Refresh a lot - but commenting that out made no difference. Just curious - a working status bar would be a really helpful visual cue for this particular long-running script.

0 Kudos
Message 9 of 10
(7,211 Views)

Hi marispaulies,

 

The progress bar that those commands control is the same one that various functions in DIAdem uses, so if you start to display it programmatically, then run an ANALYSIS routine, for instance, the ANALYSIS routine will commandeer the progress bar.  For that reason I often use a non-modal dialog with the MsgBoxDisp() command instead to inform the user of various steps in an ongoing script.

 

Set Dlg = New NonModalDlg
NumSecs = 9
FOR i = 0 TO NumSecs
  Dlg.Update "Non-modal MsgBox display:  Second " & i & " of " & NumSecs
' Call MsgOut("Non-modal MsgBox display:  Second " & i & " of " & NumSecs)
  Call Pause(1)
NEXT ' i
Call MsgBoxCancel


Sub OncePerSec()
  Dim n, nMax, Msg, LastTime
  FOR n = 1 TO nMax
    IF Timer - LastTime > 1 OR Timer < LastTime THEN
      LastTime = Timer
      Msg = "Exporting Channel " & n & " of " & nMax & " ..."
      Call MsgBoxDisp(Msg, "MB_NOBUTTON", "MsgTypeNote", 0, 0, 1)
    END IF
  NEXT ' n
End Sub ' OncePerSec()

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 10 of 10
(7,151 Views)