Article Details
Id:10655
Product:finPOWER Connect
Type:NEW
Version:1.06.05
Opened:01/11/2012
Closed:07/11/2012
Released:26/11/2012
Job: J010644

Scripts can now display progress form and allow the User to cancel them

Script can now display a progress form and give the User the ability to cancel them.

The following code sample shows how to display a progress box with the ability to cancel.

Public Function Main(ByVal parameters As ISKeyValueList) As Boolean

  Const LoopMax As Integer = 1000

  Dim Cancelled As Boolean
  Dim i As Integer

  ' Assume Success
  Main = True

  ' Status Begin
  finBL.StatusProcessBegin("Progress Status Test", "Initialising", True)
  
  ' Sleep
  System.Threading.Thread.Sleep(2000)

  ' Progress
  For i = 0 To LoopMax
    ' Progress
    finBL.StatusProcess((i / LoopMax) * 100, "Item " & CStr(i), Cancelled)

    ' Cancelled?
    If Cancelled Then
      Main = False
      finBL.Error.ErrorBegin("Script was cancelled by the User.")
      Exit For
    End If

    ' Sleep
    System.Threading.Thread.Sleep(10)
  Next

  ' Status End
  finBL.StatusProcessEnd()

End Function

NOTE: Do not allow the Script to be cancelled unless your Script is running from a logical place, e.g., showing this progress or allowing the Script to be cancelled for an 'Object Events' type Script could cause issues.