JavaScript Editor js editor     Web development 

Main Page

File: ...\Samples\Solution\Reports\Wrapping.frx

The sample report, Wrapping.frx, prints an employee directory and shows how you can wrap text around graphics, alternate the print position of controls, and float controls below fields that stretch. The data environment for this report contains the EMPLOYEE table from the Testdata.dbc in the Solution project.

The Report Layout

The Title band holds the name and description of the report. The Detail band holds the field and label controls that print for each record. For each record the report displays the following four categories of information:

  • Employee name and title

  • Biography

  • Box of quick reference information such as phone and address

  • Photograph

After printing the name and title, this report wraps the text of the biography around the photograph, alternates information from left to right, and floats the box down the page relative to the biography.

Wrap Text around Graphics

To wrap the memo field around the picture, the report uses two field controls to display the contents of the memo field. The first control is above the picture to display two lines of text. The second field is also sized to show two lines of text, but is narrower and positioned next to the picture.

The first field control prints all of the words in the memo field up to the position where a break should occur to continue the words in the second control. The expression is shown below.

В Copy Code

The second field control prints the remaining words from the memo field. The expression for the second field control is shown below.

В Copy Code

The expressions for the controls use report variables to determine the words the controls display from the memo field.

  • nFirstMemoLen determines the number of characters that can be displayed in the first field without truncating. For this report, the variables value is always 185. If you use this in your own report, you will need to change this constant to match the maximum number of characters you want above the picture.

  • nMemoLen determines the length of the memo field for the current record. This variable's expression is LENC(employee.notes).

  • nSpace determines the character position of the first space after the characters displayed in the first control. This variable's expression is AT_C(CHR(32),RIGHTC(employee.notes,(nMemoLen - nFirstMemoLen))).

  • nWrapCharPos determines the character position within the memo field where the break should occur. This variable's expression is nSpace + nFirstMemoLen.

Alternate the Position of Printed Objects

In this report, the positions of the employee biography, the quick reference group, and the photograph alternate from left to right with each record. To alternate the positions, the report has two sets of controls for the parts of the report that alternate. Because two controls are used to wrap the biography text, the first control does not alternate and, therefore, does not need to be included in the two sets.

One set of controls specifies printing with the photograph on the left side. A second set specifies the printing for the photograph on the right side. The controls in both sets use a report variable, nCounter, that calculates a count which determines when the set should print. One set prints when nCounter's value is 0; the other when the value is 1. The Print When expression for the first set of controls is MOD(nCounter,2) = 0. For the second set, the expression is MOD(nCounter,2) = 1.

Float Controls below Controls That Stretch

This report prints the box of information that prints below the biography. Since the length of the biography varies with each record, the control that displays the biography information next to the picture is set to stretch and uses only the space necessary to print the contents of the field. The box that prints below the biography floats down the page depending on the length of the biography. This box is a group of field, label, and rectangle controls. To prevent the biography from printing on top of the group, the field position for each of the controls in the group is set to float.

See Also

JavaScript Editor js editor     Web development