How to loop through input file

Post any question you may have in regards to GoAnywhere Director and let our talented support staff and other users assist you.
2 posts Page 1 of 1

llovelace

Posts: 3
Joined: Wed Jan 05, 2011 9:04 am

Post by llovelace » Fri Jun 10, 2016 8:20 am
Hiya - I'm using a database task to select all records in a file. Each record contains two fields. I'd like to read one record at a time, and use the two fields in later steps. How do I control the reading and know when I'm at the end of file?

Thanks!

Support_Rick

Support Specialist
Posts: 590
Joined: Tue Jul 17, 2012 2:12 pm
Location: Phoenix, AZ

Post by Support_Rick » Wed Jun 15, 2016 5:24 pm
llovelace,

When you retrieve data from a database, you are creating a "rowset" variable as output. (Example MyData)

You can use a "ForEach" loop (Across ${MyData}) to loop through that rowset and address each record (MyRec for example).

During that looping, you can address each field of that record by it's index value -- ${MyRec[1]} ... ${MyRec[2]} -- to associate with the 1st field, 2nd field, etc...

The loop will automatically end at the end of the Rowset (${MyData}).

You could also save the values into local variables for use later if needed. (setvariable MyVar = ${MyRec[1]}.

Hope this helps!
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
2 posts Page 1 of 1