I have a string "YYNNYYYXXNYN", from which I need to be able to count the number of X(s), Y(s), and N(s). I am unable to locate a command or think of a why to programatcally do this...any help would be appreciated.
Create a formula such as to count all of them (or separate formulas if you're going to just display the values):
whileprintingrecords;
global numbervar Ns:=0;
global numbervar Xs:=0;
global numbervar Ys:=0;
global numbervar SomethingElse:=0;
numbervar X; // used as the counter
for x := 1 to length({AtsAddrs.chvAddr1}) do(
if mid({AtsAddrs.chvAddr1},X) = "N" then
Ns:=Ns+1
else
if mid({AtsAddrs.chvAddr1},X) = "X" then
Xs:=Xs+1
else
if mid({AtsAddrs.chvAddr1},X) = "Y" then
Ys:=Ys+1
else
SomethingElse := SomethingElse+1
);
Now you can us the results in other formulas, such as:
whileprintingrecords;
global numbervar Ns;
If Ns > 0 then
"I found " + totext(Ns,0) + " of the value N"
else
"There are no N's"
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.