Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to print text vertically

Formula Help

How to print text vertically

by  HowardHammerman  Posted    (Edited  )
A tip in the May, 2002 issue of the Crystal Care eNews for Crystal Reports newsletter showed how to take the text in a text object and print the letter vertically.

BUT suppose you wanted to print a character field from your database in the same way?

In the following example we are using a For loop. This is available in Crystal 8.5 and above. We will print the field NAME vertically.

Here is how to do it:

Create a formula field with the following syntax:

WhilePrintingRecords;
numbervar stlen := length(trim({EMPLOYEE.NAME}));
numbervar k ;
local stringvar output;
for k := 1 to stlen do
(
output := output + {EMPLOYEE.NAME}[k]+chr(13);
);
output := output + chr(13)

Insert the formula in your report and then right-click, pick ôFormat Fieldö and
Check the ôcan growö property.

Here is how it works:
Line 2 stores the length of the field striped of blanks into the variable stlen.
Line 3 declares a number variable, k. We will use this to control the number of loops.
Line 4 declares a string variable to use to store the output. It is important to include the ælocalÆ qualifier or the field will keep growing from record to record!
Line 5 sets up the loop. We will go through the loop the number a number of times equal to the current value of stlen.
Line 7 parses the database field. The sub-string operator [ ] (brackets) picks out the kth letter of the field and appends it to the growing output string field. After each letter we are inserting a hard return. The CHR function translates a number to its ASCII equivalent. CHR(13) is equivalent to pressing the ôreturnö key on your keyboard.
Line 9 adds one more return at the end of the string for formatting purposes.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top