Lotus Notes FAQ Visit Our Sponsor!

How do you display progress to the user via LotusScript?

If you are processing a large collection of documents, it would be useful to show the user progress so they don't think your application has hung. Here is a method to show a progress meter in the status bar in Notes:

REM "From Erden Eruc @ NGSINC"

Dim i As Integer
Dim s As String
     
'Is this 100 meter dash? no it is a meter with 100 dashes :)
     
s = "--------------------------------------------"&_
"--------------------------------------------------------"
For i = 1 To 100
  s = Left( Chr(1) & s, 100 )
  If i<10 Then
    Print "Percent Done:    "& Str(i)&"% - " & s 
  Elseif i = 100 Then
    Print "Percent Done:"& Str(i)&"% - " & s
  Else
    Print "Percent Done:  "& Str(i)&"% - " & s
  End If
Next
Print "Percent Done: 100% - Job complete..."


For a Win32-specific version that uses Notes functions (note: this is a dangerous thing to do, but if you really must have a graphical progress bar..):
Const NPB_TWOLINE% = 1
Const NPB_STATUSBAR% = 32

Declare Function NEMProgressBegin Lib "nnotesws.dll" ( Byval wFlags As Integer ) As Long
Declare Sub NEMProgressDeltaPos Lib "nnotesws.dll" ( Byval hwnd As Long, Byval dwIncrement As Long )
Declare Sub NEMProgressEnd Lib "nnotesws.dll" ( Byval hwnd As Long )
Declare Sub NEMProgressSetBarPos Lib "nnotesws.dll" ( Byval hwnd As Long, Byval dwPos As Long)
Declare Sub NEMProgressSetBarRange Lib "nnotesws.dll" ( Byval hwnd As Long, Byval dwMax As Long )
Declare Sub NEMProgressSetText Lib "nnotesws.dll" ( Byval hwnd As Long, Byval pcszLine1 As String, Byval pcszLine2 As String )

' From Mark Dixon @ Ives

Dim hwnd As Long
Dim i As Long
Dim j As Long
     
'Create the progress bar
hwnd = NEMProgressBegin( NPB_TWOLINE )
     
'Set the bar range - the default is 100
NEMProgressSetBarRange hwnd, 200
     
'Display some text on the dialog.  The second line is ignored if NPB_TWOLINE not specified
NemProgressSetText hwnd, "Calculating..", "Start"
     
For i = 0 To 200
  'Simple delay loop to give us time to see whats going on
  For j = 0 To 5000     
  Next
  'Update the bar position - we could also use NEMProgressDeltaPos hwnd, 1 here
  NEMProgressSetBarPos hwnd, i 
  'Update the text at halfway
  If i = 100 Then
    NEMProgressSetText hwnd, "Calculating", "Half way"
  End If
Next

'Destroy the dialog when we're done
NEMProgressEnd hwnd


Applies to Notes Versions: 4 4.5 4.6 5
Last Modified: February 24, 1998