Skip to content

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.
  • llovelace Offline
  • Posts: 3
  • Joined: Wed Jan 05, 2011 9:04 am

How to loop through input file

Post by llovelace »

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 Offline
  • Support Specialist
  • Posts: 590
  • Joined: Tue Jul 17, 2012 2:12 pm
  • Location: Phoenix, AZ
  • Contact:

Re: How to loop through input file

Post by Support_Rick »

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
Post Reply