dbTalk Databases Forums  

ActiveX Script Task syntax

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss ActiveX Script Task syntax in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Olivia
 
Posts: n/a

Default ActiveX Script Task syntax - 03-01-2004 , 07:45 PM






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



Reply With Quote
  #2  
Old   
Jim Young
 
Posts: n/a

Default Re: ActiveX Script Task syntax - 03-01-2004 , 07:59 PM






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

Quote:
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





Reply With Quote
  #3  
Old   
Darren Green
 
Posts: n/a

Default Re: ActiveX Script Task syntax - 03-02-2004 , 02:06 AM



Why not use a DataPump task?


"Jim Young" <thorium48 (AT) hotmail (DOT) com> wrote

Quote:
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







Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.