List question

Does anyone know a simple way in formula to calculate how many of the same chanracter there is in a list.i.e.

List=a,b,c,c,d,d,e

I want to ask how many times c is in this list and get back 2.

Subject: List question

You selected “all releases” for your question. If you’re not using ND6, @For is not available.

Try counting the number of elements before and after replacing the asked value with nothing.

listDiff := @Trim(@Replace(listOrig; “c”; “”));

countDiff := @Elements(listOrig) - @Elements(listDiff)

Subject: Thanks to both of you for your answers.

Subject: List question

This does it using the @For function.

count := 0;

List2 := “C”; <<- or whatever value you want to check for.

@For(n := 1;

n <= @Elements(List1);

n := n + 1;

@If(List1[n] = List2 ; Count := Count + 1 ; “”) ;

@Prompt([Ok] ; @Text(n) ; List1[n] + " … " + @Text(Count))

);

Count