I was wondering if you would kindly explain what each line does in the formula you provided below? I'm trying to learn more and would like to visualize what each line does in the process. Thanks. kg.
whileprintingrecords;
stringvar p;
numbervar i;
if remainder(i,40)=0 then(
i := 0;
p := "";
);
whileprintingrecords;
stringvar x;
numbervar i := i + 1;
stringvar p;
x := {User.name_last}[1];
if i = 1 then
p := x else
p := replicatestring(chr(9),i-1)+x;
p
Whileprintingrecords - In most cases, if you are accumulating across records, it needs to occur on the second pass, or while printing records.
The numbervar and stringvar lines give the variables their names: x, i, p. You could name these anything you like.
The i variable is a count where 1 is added to the current value of i. Since this is in the page footer, it accumulates only when the page changes.
X:= {User.name_last}[1]; //This sets x equal to the first character in the name by using a subscript of 1.
The next lines say that if it is page 1, then a new string p is equal to the initial; if any other page, there will be one or more tabs corresponding to the number of the page minus 1, followed by the initial. Without the reset formula, this would keep wrapping and moving down the page (if you increased the height of the formula in the page footer to see it).
Reset formula: First you see the whileprintingrecords and the variables being referenced, and then the reset formula itself. It says when i reaches 40 (the right hand margin in your case), set i to 0 so that the next page i= 1 and the initial will appear on the left—as long as you also set p to the state of emptiness so that p does not instead wrap. The parentheses around both declarations make the remainder condition (the remainder of i divided by 40 = 0 which is the same as the pagenumber being perfectly divisible by 40) apply to both i and p.
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.