How to work the next string in an array

Hi all

I have an array of strings which will contain ‘reference numbers’ e.g “4343”,“5454”,“6566”. I’ve got a flow going where it will get the length of this array (3 in this example) and a counter going. In a flow decision if the Counter < Array Length it will loop back around and the plan is to work the next reference number.

The problem I have is, the component that does the work, I want to pass a reference number in each time. I have an in argument called ‘in_strReference’. What code do I write in that argument so it picks up the next reference number from the array? So it’ll work ref number ‘4343’ then ‘5454’ etc

Thanks in advance,
Jordan

Hi @jordrowley
try for each item in strarray and check the length like

item.ToString.Length<4

Thanks
Ashwin S

1 Like

Hi,

It will be yourStrArray(Counter+1)

However, when “Counter” equals “Array.Length-1” (when current ref is “6566” in your sample), it will throw IndexOutOfRangeException, because there is no next ref. Is there any rule for it?

Regards,

Hi Yoichi

Thank you, yes that is what has happened

I’ve started the counter at -1 to make sure it works the first item in the array and in the flow decision is Counter < RefNumbers.Length

Please can I ask how I can stop the error from occurring? The end result is that when it’s worked the last reference number (which can vary from queue item to queue item) it goes to false

Thanks
Jordan

Hi,

How about to change FlowDecision condition from “Counter < Array Length” to “Counter < Array Length-1”? Probably it prevents exception but I’m not sure if it is right from the view point of business logic.

Regards,

1 Like

Thanks Yoichi

Spoke to a colleague who changed it around to this

in the flow decision it says Counter < RefNumbers.Length so when it gets to (in this case) 3 it goes to false and I don’t get the error above

Thanks for your help
Jordan

1 Like