![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I use this script to create a CSV file from a space delimiter file. Now I want to use the same script to create a tab delimiter file from a tab delimiter file using with the same global variables. The only extra thing is that there is a condition -> Col4=X. I just need help with the syntax since I'm not very familiar with ActiveX. Thanks in advance for your help. Function Main() Dim MyVar Dim s Dim M Dim MYPath Set fileInputHandler = CreateObject ("Scripting.FileSystemObject") Set fileOutputHandler = CreateObject ("Scripting.FileSystemObject") SAPPath=DTSGlobalVariables("MYPath").value ' Plan to use the Global Variable for the File Name Set My_Input = fileInputHandler.OpenTextFile(MYPath & "my_input_file.txt", 1) Set My_Output_s = fileOutputHandler.CreateTextFile(MYPath &"my_output_file.txt", True) 'While Not My_Input.AtEndOfStream Do While My_Input.AtEndOfStream <> True s = My_Input.readLine MyVar = Mid(s, 5,8) Col1 M=MyVar&"|" MyVar = Mid(s, 1,4) Col2 M=M&MyVar&"|" MyVar = Mid(s, 28,20) 'Col3 M=M&MyVar&"|" MyVar = Mid(s, 13,15) 'Col4 M=M&MyVar My_Ouput_s.WriteLine(M) 'Wend Loop My_Input.close My_Output_s.close Main = DTSTaskExecResult_Success End Function |
#3
| |||
| |||
|
|
You're assign the value of Col4 to MyVar so just do your test on that variable. Example: MyVar = Mid(s, 13,15) 'Col4 If MyVar = "X" Then Do Something End If "Olivia" <anonymous (AT) discussions (DOT) microsoft.com> wrote in message news:4f9e01c3fff8$04a5c190$a301280a (AT) phx (DOT) gbl... I use this script to create a CSV file from a space delimiter file. Now I want to use the same script to create a tab delimiter file from a tab delimiter file using with the same global variables. The only extra thing is that there is a condition -> Col4=X. I just need help with the syntax since I'm not very familiar with ActiveX. Thanks in advance for your help. Function Main() Dim MyVar Dim s Dim M Dim MYPath Set fileInputHandler = CreateObject ("Scripting.FileSystemObject") Set fileOutputHandler = CreateObject ("Scripting.FileSystemObject") SAPPath=DTSGlobalVariables("MYPath").value ' Plan to use the Global Variable for the File Name Set My_Input = fileInputHandler.OpenTextFile(MYPath & "my_input_file.txt", 1) Set My_Output_s = fileOutputHandler.CreateTextFile(MYPath &"my_output_file.txt", True) 'While Not My_Input.AtEndOfStream Do While My_Input.AtEndOfStream <> True s = My_Input.readLine MyVar = Mid(s, 5,8) Col1 M=MyVar&"|" MyVar = Mid(s, 1,4) Col2 M=M&MyVar&"|" MyVar = Mid(s, 28,20) 'Col3 M=M&MyVar&"|" MyVar = Mid(s, 13,15) 'Col4 M=M&MyVar My_Ouput_s.WriteLine(M) 'Wend Loop My_Input.close My_Output_s.close Main = DTSTaskExecResult_Success End Function |
![]() |
| Thread Tools | |
| Display Modes | |
| |