Page 1 of 1

Job Sequence question - loops and user variables

Posted: Tue Jan 13, 2015 3:48 am
by ArndW
I have a Job Sequence which loops multiple times, calling a job which returns a single value each iteration (via UserStatus) to the calling sequence.

After n iterations of this loop I would like to have a comma-separated list of those returned values in a variable that I can then pass to yet another job.

Unfortunately the User Variable Activity stage variables do not allow the construct "A = A : <new value>" and I can't see a simple way to do this; but perhaps I'm overthinking the problem and am missing some simple solution that someone else here might find.

I've temporarily worked around the issue by declaring a user-written BASIC function which uses a COMMON block to statically store a variable and append strings to it on each call, but this seems to be a bit too complicated.

Posted: Tue Jan 13, 2015 4:23 am
by ray.wurlod
Maybe an Execute Command activity involving echo with the >> indirection operator to accumulate the values in a file then, outside the loop, another Execute Command activity to cat the file? Of course you'd also need to ensure that the file did not exist or was empty before the loop begins.

Posted: Tue Jan 13, 2015 5:54 am
by ArndW
Considering that my routine is a 2-liner, that might be the easier way to go after all. I was hoping that there was some "official" method available within the loop to accumulate a value that I'd missed.

Re: Job Sequence question - loops and user variables

Posted: Tue Jan 13, 2015 2:40 pm
by vibwipro
Execute Command Stage will be an option for this logic to implemented. Every time output value will be over written to existing file with new value concatenated to it. :idea: