I want to display names of persons on the occurrence labels when opening a case that has been previously entered. This way I'll see names instead of population(1), population(2) etc when opening a case in android. I've tried the following:
PROC PART_A //This is the level proc
onfocus
do i = 1 while i <= totocc(POPULATION000) //DEBUG: totocc and count both return 0 if executed before the roster that they are referring to
setocclabel(POPULATION000(i), strip(FIRST_NAME(i))); //first roster
setocclabel(POPULATION001(i), strip(FIRST_NAME(i))); //second roster
enddo;
I tried both totocc() and count() but It turns out that both of them evaluate to 0 until I actually enter the roster. This results in all the occurrence labels being changed to only the name of the first person. Is there a way to get the total number of roster items or to loop through all the roster items?
There are a series of occurrence functions that you could look into, but I usually write code like this:
PROC PART_A //This is the level proc
onfocus
do i = 1while i <= maxocc(POPULATION000) and FIRST_NAME(i) <> "" setocclabel(POPULATION000(i), strip(FIRST_NAME(i))); //first roster setocclabel(POPULATION001(i), strip(FIRST_NAME(i))); //second roster enddo;