Page 1 of 1

Numeric Loop Value

Posted: Mon Feb 09, 2009 2:24 pm
by Ahimsa
I have a numeric loop. Loop end value is based on the number value in the .txt file
I have a execute command stage to read the value from the .txt file.
Execute command stage is having line this - cat test.txt
e.g. if this file is having the number 10, loop should be executed for 10 times.
in the loop, I am using the expresion - Convert(getCountValue.$CommandOutput,@FM,1)

but I am getting error saying not numeric value.

Would appreciate your suggestions.

Posted: Mon Feb 09, 2009 2:40 pm
by chulett
Your Convert() syntax is wrong, looks more like Field() syntax.

Code: Select all

Convert(@FM,"",getCountValue.$CommandOutput)
Assuming you want to strip any field marks from the output.

Posted: Mon Feb 09, 2009 2:51 pm
by Ahimsa
I tried it and I am getting error -

Loop final value not numeric (Convert(@FM,"",2) - cannot execute

Posted: Mon Feb 09, 2009 3:19 pm
by chulett
Sounds like you're doing this directly in the Loop Definition "To:" field and, while this can work in a Trigger expression, you cannot do it directly in the Loop Definition. You'd either need to send this in as a job parameter to the Sequence job and use the job parameter in the Start Loop stage or use a Routine Activity rather than the Execute Command stage.

Do basically the same thing in a routine using DSExecute: cat the file and then convert() to strip the field marks before passing back the count as the Answer. Then you can reference that in the Start Loop:

Code: Select all

#RoutineActivityStageName.$ReturnValue#

Re: Numeric Loop Value

Posted: Mon Feb 09, 2009 10:25 pm
by SURA
Ahimsa wrote:I have a numeric loop. Loop end value is based on the number value in the .txt file
I have a execute command stage to read the value from the .txt file.
Execute command stage is having line this - cat test.txt
e.g. if this file is having the number 10, loop should be executed for 10 times.
in the loop, I am using the expresion - Convert(getCountValue.$CommandOutput,@FM,1)

but I am getting error saying not numeric value.

Would appreciate your suggestions.
You can check this one.

1) Execute Command (cat file name); In the triggersUse this
Trim(Convert(@FM : @VM : @SM : @TM : @IM : Char(10) : Char(13) : Char(9), ' ', StageName.$CommandOutput))<>''
2) In the start loop you can always use 1 from and StageName.$CommandOutput is for To.


Thanks
Ram

Posted: Tue Feb 10, 2009 6:39 am
by chulett
Did you 'check' this suggestion? Putting an expression in a trigger isn't going to help as you can't actually change the $CommandOutput value from there.

Posted: Tue Feb 10, 2009 3:35 pm
by Ahimsa
Trigger is not changing the value of command output. So still the same problem.

Posted: Tue Feb 10, 2009 3:45 pm
by chulett
... with still the same answer I posted yesterday. :wink: