![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| ||||||
| ||||||
|
|
-----Original Message----- Ok, I have my activex script that can loop through and remove certain file extensions that I don't but when it completes that section it doesn't allow the files left to process. It stops my dts with a success leaving the other process steps as not run. I am trying to find a better solution to this existing problem as instead of loop through the enter directory and working with the last file it comes to I want it to work with the first file and if it meets the a.dbf,c.dbf,s.dbf,t.dbf then I want it to process those steps other wise delete anyfile that doesn't have those extensions. Code below... Function Main() Dim pkg Dim ConTextFileST Dim ConTextFileTR Dim ConTextFileDB Dim ConTextFileDB2 Dim stpEnterLoopST Dim stpEnterLoopTR Dim stpEnterLoopDB Dim stpEnterLoopDB2 Dim fso Dim fil Dim fold Dim stpFinished 'Set Package reference set pkg = DTSGlobalVariables.Parent set fso = CREATEOBJECT ("Scripting.FileSystemObject") 'Our Pump Steps set stpEnterLoopST = pkg.Steps ("DTSStep_DTSDataPumpTask_1") set stpEnterLoopTR = pkg.Steps ("DTSStep_DTSDataPumpTask_2") set stpEnterLoopDBA = pkg.Steps ("DTSStep_DTSDataPumpTask_3") set stpEnterLoopDBC = pkg.Steps("DTSStep_DTSDataPumpTask_4") set stpFinished = pkg.Steps ("DTSStep_DTSActiveScriptTask_5") stpEnterLoopDBA.DisableStep = TRUE stpEnterLoopDBC.DisableStep = TRUE stpEnterLoopST.DisableStep = TRUE stpEnterLoopTR.DisableStep = TRUE stpFinished.DisableStep = TRUE if ShouldILoop = True THEN if DTSGlobalVariables ("gv_FileExtension").Value = "dbf" then select case right (DTSGlobalVariables("gv_FileFullName").Value,5) case "a.dbf" 'If fso.FileExists (DTSGlobalVariables("gv_temppath") & "tempa.dbf") = True Then ' fso.DeleteFile (DTSGlobalVariables("gv_temppath") & "tempa.dbf"), True 'End If fso.MoveFile DTSGlobalVariables("gv_FileFullName").Value ,DTSGlobalVariables("gv_temppath") & "tempa.dbf" 'DTSGlobalVariables ("gv_FileName").Value = "tempa.dbf" stpEnterLoopDBA.DisableStep = False stpEnterLoopDBA.ExecutionStatus = |
|
case "c.dbf" 'If fso.FileExists (DTSGlobalVariables("gv_temppath") & "tempc.dbf") = True Then ' fso.DeleteFile (DTSGlobalVariables("gv_temppath") & "tempc.dbf"), True 'End If fso.MoveFile DTSGlobalVariables("gv_FileFullName").Value ,DTSGlobalVariables("gv_temppath") & "tempc.dbf" DTSGlobalVariables ("gv_FileName").Value = "tempc.dbf" stpEnterLoopDBC.DisableStep = False stpEnterLoopDBC.ExecutionStatus = |
|
case "s.dbf" 'If fso.FileExists (DTSGlobalVariables("gv_temppath") & "temps.dbf") = True Then ' fso.DeleteFile (DTSGlobalVariables("gv_temppath") & "temps.dbf"), True 'End If fso.MoveFile DTSGlobalVariables("gv_FileFullName").Value ,DTSGlobalVariables("gv_temppath") & "temps.dbf" DTSGlobalVariables ("gv_FileName").Value = "temps.dbf" |
|
stpEnterLoopST.DisableStep = False stpEnterLoopST.ExecutionStatus = |
|
case "t.dbf" ' If fso.FileExists (DTSGlobalVariables("gv_temppath") & "tempt.dbf") = True Then ' fso.DeleteFile (DTSGlobalVariables("gv_temppath") & "tempt.dbf"), True ' End If fso.MoveFile DTSGlobalVariables("gv_FileFullName").Value ,DTSGlobalVariables("gv_temppath") & "tempt.dbf" DTSGlobalVariables ("gv_FileName").Value = "tempt.dbf" stpEnterLoopTR.DisableStep = False stpEnterLoopTR.ExecutionStatus = |
|
End select End if 'dbf else 'msgbox "Finished. Disabling DataPumps And Exiting" 'call Archive2Transfer stpFinished.DisableStep = False End if Main = DTSTaskExecResult_Success End Function Function ShouldILoop Dim fso Dim fil Dim fold Dim pkg Dim counter set pkg = DTSGlobalVariables.Parent set fso = CREATEOBJECT ("Scripting.FileSystemObject") set fold = fso.GetFolder(DTSGlobalVariables ("gv_FileLocation").Value) counter = fold.files.count ' So long as there are text files in the directory carry on if counter >= 1 then for each fil in fold.Files DTSGlobalVariables ("gv_FileFullName").Value = fil.path DTSGlobalVariables ("gv_FileName").Value = fso.GetFileName(fil.Path) DTSGlobalVariables ("gv_FileExtension").Value = fso.GetExtensionName(fil.Path) DTSGlobalVariables ("gv_FileName2").Value = fso.GetFileName(fil.Path) IF InStr( 1, "a.dbf,c.dbf,s.dbf,t.dbf", StripOffFilePart( DTSGlobalVariables("gv_FileFullName").Value,".")) Then 'leave this file in trasfer directory to use Else 'file not used delete and move on fso.DeleteFile DTSGlobalVariables ("gv_FileFullName").Value end if ShouldILoop= CBool(True) Next else ShouldILoop = CBool(False) End if End Function Function StripOffFilePart(sFilename,sString) Dim nExtStartPos on error resume next nExtStartPos = InStrRev(sFilename, Trim(sString)) StripOffFilePart = sFilename If nExtStartPos > 0 Then StripOffFilePart = Trim (Mid(sFilename, nExtStartPos - 1,60 )) End Function *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! . |
#3
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |