AnsweredAssumed Answered

Repetition - count of

Question asked by dzittin on Mar 15, 2012
Latest reply on Mar 15, 2012 by philmodjunk

Title

Repetition - count of

Post

Simple Q, but I cannot find the answer. If I create a repetition, say:

$a[1] = "x"

$a[2] = "y"

$a[3] = "z"

 

How can I tell how many repetitions are in the list. I know (it's 3 :-) this example is simple, but I want to create a loop structure that processes each of the a[i] values and this list can grow (or shrink) by adding a value to the end (last+1). I can manually change the exit condition on the loop, but this is not as robust from a maintenance standpoint. Yes, I realize I can also use a list (ValueCount, GetValue), but the code isn't as readable as I would like, especially when the lists are long.

 

It would be nice if FM had a Unix-like

foreach $str in "x" "y" "z"

do

somethingto($str)

done

construct (I put this in the suggestion box). I seem to need this loop on a list functionality fairly frequently and can only think of value lists or repetitions to manage such a loop. If anyone has a better idea, I am all ears. In any event, I would like to know how to determine the valid number of elements in a repetition.

As usual, TIA for the good info flow on this Forum.

-D

Outcomes