dbTalk Databases Forums  

Very simple question

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


Discuss Very simple question in the microsoft.public.sqlserver.dts forum.



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

Default Very simple question - 05-07-2004 , 02:44 PM






I am writing an ActiveX Script using VB Script Language in my DTS. One place
I have to use a FOR EACH .. NEXT statement. Now there is a condition i am
checking inside this statement and if it pass i want to go to the next
element without executing the rest of the statements in the loop. Now this
is very basic question but i could not find a statement which allows me to
do that. I tried LOOP but it is giving me this error message :

Error Source : Microsoft Data Transformation Services (DTS) Package

Error Description : Error Code: 0
Error Source= Microsoft VBScript compilation error
Error Description: 'loop' without 'do'

Error on Line 27


Here is my code :

FOR EACH v_File IN v_Files
v_FileName = v_File.name
IF Right ( v_FileName, 3 ) = "LOC" THEN 'The condition pass so
go to the next v_File
v_FileDate = Right ( v_FileName , 8 )
...
NEXT


Is there any thing I am missing? Thanks

JY



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

Default Re: Very simple question - 05-07-2004 , 04:10 PM






In message <OUwHAzGNEHA.1312 (AT) TK2MSFTNGP12 (DOT) phx.gbl>, J Y
<jy1970us (AT) hotmail (DOT) com> writes
Quote:
I am writing an ActiveX Script using VB Script Language in my DTS. One place
I have to use a FOR EACH .. NEXT statement. Now there is a condition i am
checking inside this statement and if it pass i want to go to the next
element without executing the rest of the statements in the loop. Now this
is very basic question but i could not find a statement which allows me to
do that. I tried LOOP but it is giving me this error message :

You can use Exit For, like this

Dim bFlag

For Each object In collection
If object.Property = True Then
'Set something to say we exited because of test, not
just fall out bottom
bFlag = True
Exit For
End If
Next

If bFlag Then
' We found what we wanted
Else
' Just ended loop when we ran out of work
End If


--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server professionals
http://www.sqlpass.org



Reply With Quote
  #3  
Old   
J Y
 
Posts: n/a

Default Re: Very simple question - 05-07-2004 , 04:41 PM



ok may be i explain it wrong so thats what I want to do:

For Each object in collection
If object.Property = True Then go to next object in collection
else execute these statement:
1st statement
2nd statement
....
next

I work in PowerBuilder (PB) and CONTINUE is used to do what I want. I am
looking for the equivalent in VBScript Language in ActiveX. In PB I can do
it like :

For Each object in collection
If object.Property = True Then Continue
1st statement
2nd statement
....
next

Thanks

JY

"Darren Green" <darren.green (AT) reply-to-newsgroup-sqldts (DOT) com> wrote

Quote:
In message <OUwHAzGNEHA.1312 (AT) TK2MSFTNGP12 (DOT) phx.gbl>, J Y
jy1970us (AT) hotmail (DOT) com> writes
I am writing an ActiveX Script using VB Script Language in my DTS. One
place
I have to use a FOR EACH .. NEXT statement. Now there is a condition i am
checking inside this statement and if it pass i want to go to the next
element without executing the rest of the statements in the loop. Now
this
is very basic question but i could not find a statement which allows me
to
do that. I tried LOOP but it is giving me this error message :


You can use Exit For, like this

Dim bFlag

For Each object In collection
If object.Property = True Then
'Set something to say we exited because of test, not
just fall out bottom
bFlag = True
Exit For
End If
Next

If bFlag Then
' We found what we wanted
Else
' Just ended loop when we ran out of work
End If


--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server professionals
http://www.sqlpass.org




Reply With Quote
  #4  
Old   
Partha Mandayam
 
Posts: n/a

Default Re: Very simple question - 05-07-2004 , 04:47 PM



Rewrite this as

IF Right ( v_FileName, 3 ) <> "LOC" THEN 'The v_FileDate =
Right ( v_FileName , 8 )
end if

Then if it is "LOC", it will automatically go to the next file

Regards

Partha Mandayam
Software Consultant
Home page: http://partha.tripod.com


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Reply With Quote
  #5  
Old   
Partha Mandayam
 
Posts: n/a

Default Re: Very simple question - 05-07-2004 , 09:20 PM



In VB there is no continue statement hence we use a reverse approach as
follows:

For Each object in collection
'if false
If object.Property = false Then
execute
1st statement
2nd statement
....
end if
'if property is true it will automatically go to the next object
next



Regards

Partha Mandayam
Software Consultant
Home page: http://partha.tripod.com


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

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.