Search code examples
scriptingvbscriptspss

Notify user of progress in SPSS


I have the below SPSS code in my script;

MsgBox "Progressing"
For iCaseCount = 1 To iNumberOfCases
     'my code here
Next

I want to remove the MsgBox and place 'it' inside the loop and replace it's content with; "Progressing record: " & " of " & iNumberOfCases

Is there any way to achieve what I want?


Solution

  • I finally found a way to show the progress via Internet Explorer.

    Below is the VB Script Code.

    Dim objExplorer
    Set objExplorer = CreateObject("InternetExplorer.Application")
    objExplorer.navigate "about:blank" : objExplorer.Width = 350 : objExplorer.Height = 80 : objExplorer.toolbar = False : objExplorer.menubar = False : objExplorer.statusbar = False : objExplorer.Visible = True
    
    For iCaseCount = 1 To iNumberOfCases
        DisplayProgress(objExplorer, iCaseCount, iNumberOfCases)
        'my code here
    Next
    
    objExplorer.Quit
    Set objExplorer = Nothing
    

    Method to show progress

    Sub DisplayProgress(ByVal x As Object, ByVal stage As Long, ByVal total As Long)
         'in code, the colon acts as a line feed
         x.Refresh
         x.document.write "<font color=black face=Arial>"
         x.document.write  "Processing record " & stage & " of " & total
         x.document.write "</font>"
    End Sub