Development‎ > ‎VBScript‎ > ‎

File Processing utility - Starter Kit

Code:
'*********************************************************************************
'* Function signature:
'* Description:
'*                  
'*
'* Parameters
'*
'*
'*
'* Return Value
'*
'*********************************************************************************
'Array of the files to preocess
ReDim aFiles(-1)
 
'if the scrip has been called with parameters create list of files based on those parameres
If WScript.Arguments.Count > 0 Then
      Dim iCurrentFile
     
      'This loop will create a list of files passed to the script
      For iCurrentFile = 0 To WScript.Arguments.Count - 1
            ReDim Preserve aFiles(UBound(aFiles)+1)
            aFiles(UBound(aFiles)) = WScript.Arguments(iCurrentFile)
      Next
     
Else 'otherwise show dialog box to locate a file
      'Create OpenFile dialog box
      Dim objDialog : Set objDialog = CreateObject("SAFRCFileDlg.FileOpen")
     
      'This will display open file dialog box on the screen and return
      'true if the file has been choosen
      If objDialog.OpenFileOpenDlg then  
            ReDim Preserve aFiles(UBound(aFiles)+1)
            aFiles(UBound(aFiles)) = objDialog.FileName          
      End If
     
      'Clean up
      Set objDialog = Nothing
End If
 
 
For Each sFilePath In aFiles
      Main(sFilePath)
Next
'------------------------------------------------------------------------------------------------------------
 
 
'------------------------------------
' Main function implementation
'------------------------------------
Sub Main(sFilePath)
      MsgBox sFilePath
End Sub

Comments