I have 2 activex scripts:
1. Change input file name to filename with yesterday's date
2. Check to see if that file exists (if it doesn't, I delay for some time and loop it back to check)...
Both scripts run independently, but have issues running sequentially -- no errors, just ignores second script.
I'm guessing it has something to do with variable declaration or something but I am struggling identifying the issue.
Thoughts?
<CODE>
Option Explicit
Function Change()
Dim oConn, sFilename
' Filename format - rt_daily_20031013
sFilename = "\\nfstmp\sas_share\switzerd\rt_daily_" &Year(Now())
If Month(Now()) < 10 Then sFilename = sFilename & "0" & _
Month(Now()) Else sFilename = sFilename & Month(Now())
If Day(Now()) < 10 Then sFilename = sFilename & _
"0" & Day(Now()) Else sFilename = sFilename & Day(Now())-3
sFilename = DTSGlobalVariables("\\nfstmp\sas_share\switzerd\".Value & _
sFilename & ".csv"
'\\nfstmp\sas_share\switzerd' Set oConn = DTSGlobalVariables.Parent.Connections("Text File (Source)"
Set oConn = DTSGlobalVariables.Parent.Connections("Connection 1"
oConn.DataSource = sFilename
'Set oConn = Nothing
Change = DTSTaskExecResult_Success
msgbox "Done Step1"
End Function
'****************************************
'****************************************
'****************************************
'******* SECOND ACTIVEX SCRIPT BEGINS ***
'****************************************
Option Explicit
Function Check()
msgbox "reached step2"
Dim oFSO, oConn, sFileName, oFile
' Get the filename from my Text File connection called "Text File (Source)"
Set oConn = DTSGlobalVariables.Parent.Connections("Connection 1"
sFilename = oConn.DataSource
Set oConn = Nothing
Set oFSO = CreateObject("Scripting.FileSystemObject"
' Check File Exists first
If Not oFSO.FileExists(sFilename) Then
' Return Error
Check = DTSTaskExecResult_Failure
Else
' Get file object
Check = DTSTaskExecResult_Success
Set oFile = oFSO.GetFile(sFilename)
End If
Set oFile = Nothing
Set oFSO = Nothing
End Function
</CODE>
1. Change input file name to filename with yesterday's date
2. Check to see if that file exists (if it doesn't, I delay for some time and loop it back to check)...
Both scripts run independently, but have issues running sequentially -- no errors, just ignores second script.
I'm guessing it has something to do with variable declaration or something but I am struggling identifying the issue.
Thoughts?
<CODE>
Option Explicit
Function Change()
Dim oConn, sFilename
' Filename format - rt_daily_20031013
sFilename = "\\nfstmp\sas_share\switzerd\rt_daily_" &Year(Now())
If Month(Now()) < 10 Then sFilename = sFilename & "0" & _
Month(Now()) Else sFilename = sFilename & Month(Now())
If Day(Now()) < 10 Then sFilename = sFilename & _
"0" & Day(Now()) Else sFilename = sFilename & Day(Now())-3
sFilename = DTSGlobalVariables("\\nfstmp\sas_share\switzerd\".Value & _
sFilename & ".csv"
'\\nfstmp\sas_share\switzerd' Set oConn = DTSGlobalVariables.Parent.Connections("Text File (Source)"
Set oConn = DTSGlobalVariables.Parent.Connections("Connection 1"
oConn.DataSource = sFilename
'Set oConn = Nothing
Change = DTSTaskExecResult_Success
msgbox "Done Step1"
End Function
'****************************************
'****************************************
'****************************************
'******* SECOND ACTIVEX SCRIPT BEGINS ***
'****************************************
Option Explicit
Function Check()
msgbox "reached step2"
Dim oFSO, oConn, sFileName, oFile
' Get the filename from my Text File connection called "Text File (Source)"
Set oConn = DTSGlobalVariables.Parent.Connections("Connection 1"
sFilename = oConn.DataSource
Set oConn = Nothing
Set oFSO = CreateObject("Scripting.FileSystemObject"
' Check File Exists first
If Not oFSO.FileExists(sFilename) Then
' Return Error
Check = DTSTaskExecResult_Failure
Else
' Get file object
Check = DTSTaskExecResult_Success
Set oFile = oFSO.GetFile(sFilename)
End If
Set oFile = Nothing
Set oFSO = Nothing
End Function
</CODE>