This Chapter we are going to discuss about some more useful control flow items together with easy examples.
For Loop Container: which ever language programmer using they will know about For Loop iteration. Same way this For Loop Container also running. InitExpression (initialization), EvalExpression (condition) and AssignExpression (iteration)
Here I have created the variable @Counter for looping purpose.
This package I have used Script task (Get Folder List) with simple script to get the folders list from specified path. (Just for demo)
using ‘Design Script…’ to write Vb.Net Script to achieve the objective of this package.
I have written following script inside the sub Main()
Public Sub Main() ‘ ‘ Add your code here ‘ Dts.TaskResult = Dts.Results.Success Dim Dir As Directory Dim SDir As String Dim SDirs As String If Dir.Exists("C:\PHP") Then For Each SDir In Dir.GetDirectories("C:\PHP") SDirs += SDir & vbCrLf Next End If MsgBox("Directories List : " & SDirs) End Sub
Just right click on for loop container to test the script using ‘Execute container’
Script will be return directory list from specified path (Just for demo – In real time scenario avoid messages.)
Completion of successful execution will be displayed with Green color.
This chapter we have learned additionally how to test the task (or) container (or) package (Right click will be varied dynamically depend the selection)