From: ssdl on
Hi all

I have a DTS package which has got a active x script. Am a sql developer and
not aware of this code.

Can some one tell me what exactly the below code does::



'**********************************************************************
' Visual Basic ActiveX Script
'************************************************************************

Function Main()
' Declare FSO Related Variables
Dim sFolder
Dim fsoa
Dim fsoFolder
Dim fsoFile
Dim sFileName
Dim fileName
Dim oPKG

' Get Package Object
Set oPKG = DTSGlobalVariables.Parent

'Set Proper Folder Names
if not Right(DTSGlobalVariables("Source Folder Path").Value,1) = "\" Then
DTSGlobalVariables("Source Folder Path").Value =
DTSGlobalVariables("Source Folder Path").Value & "\"
end if

if not Right(DTSGlobalVariables("Source Folder Archive Path").Value,1) = "\"
Then
DTSGlobalVariables("Source Folder Archive Path").Value =
DTSGlobalVariables("Source Folder Archive Path").Value & "\"
end if

' Import Folder
sFolder = DTSGlobalVariables("Source Folder Path").Value

Set fso = CreateObject("Scripting.FileSystemObject")
Set fsoFolder = fso.GetFolder(sFolder)
Set fso = CreateObject("Scripting.FileSystemObject")
Set fsoFolder = fso.GetFolder(sFolder)

'Variable to determine if file exists
Dim HasFiles
HasFiles = "false"

For Each fsoFile in fsoFolder.Files
' Get first filename
sFileName = sFolder & fsoFile.Name
fileName = fsoFile.Name
HasFiles = "true"
Exit For
Next

if HasFiles = "true" then
DTSGlobalVariables("File Name") = fileName
DTSGlobalVariables("FileNames") = fileName
Set oConn = DTSGlobalVariables.Parent.Connections("Text File (Source)")
oConn.DataSource = sFileName
oPKG.Steps("DTSStep_DTSDataPumpTask_1") _
.ExecutionStatus = DTSStepExecStat_Waiting

Main = DTSTaskExecResult_Success
Else
DTSGlobalVariables("File Name") = "No File Found"
oPKG.Steps("DTSStep_DTSDataPumpTask_1") _
.ExecutionStatus = DTSStepExecStat_Inactive

Main = DTSTaskExecResult_Success
end if

End Function