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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Line throws

Status
Not open for further replies.

MaddogC

Programmer
Dec 4, 2003
134
0
0
GB
Is there any way to test when Crystal 9 throws a line during whileprintingrecords.

I have a report that prints items in columns and rows. Due to the nature of the data I need to populate arrays and then print the items of the array using whileprintingrecords.

To ensure that the rows align correctly I pad the data to it's max field size using spaces and then print out in a monospaced font.

Unfortunately Crystal still spaces out the words on the report to ensure that part words don't display. the only way that I can think of getting the rows to line up is to calculate how many lines were written. Any other ideas?

 
This is hard to follow. Please show some sample data.

-LB
 
Crystal doesn't give you detailed control of a 'text object'. It does offer left-aligned, right-aligned, centred and justified. Have you got the wrong one set?

If that's not it, please do as lbass says, show us what you get and what you want.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
For each column in my report I have 3 formulae.

Formula 1 resets the variables and goes in the group header, which is suppressed

Formula 2 adds an item to an array, when the first few characters in the data match the word "need" in this example. It goes in the details section and again is suppressed.

Formaula 3 goes in the footer. I loop through the array and print out each element.

my report has 6 columns. I need the first element in the first array, column 1 to line up with the first element in the second array, column 2.

To achieve this I have padded each element in the array to the max field size for the field, 255 and have used a monospaced font.

My problem is that either Crystal or the printer drivers then space words out to ensure part words don't appear on each line. This means that one column may have more lines than another and hence my rows don't line up correctly.

My code is below

Formula

Formula 1
---------
whileprintingrecords;
stringvar array ArrayContacts;
redim ArrayContacts[20];
numbervar Contactscounter := 0;

Formua 2
--------
WhilePrintingRecords;
stringvar array ArrayContacts;
numbervar Contactscounter;
local numbervar lenStr;
local stringvar MyVal;
local numbervar x;
local stringvar strSpaces;

MyVal :="";

strSpaces := "";
if Left({Command.YYY},4) = "NEED" then
(
if {Command.ZZZ} <> "0" then
(Contactscounter := Contactscounter + 1;

if Contactscounter <= 1000 then
(
Redim Preserve ArrayContacts[Contactscounter];
MyVal := {Command.ZZZ};
lenStr := Len(MyVal);

for x := 1 to (255)
do
(
if x > lenStr then
(
MyVal := MyVal & "x";
)
);

ArrayContacts[Contactscounter] := MyVal;
)
else
(
for x := 1 to (255)
do
(
MyVal := MyVal & "x";
);
ArrayContacts[Contactscounter] := MyVal;
)
)

);

ArrayContacts[Contactscounter];

Formula 3
---------
whileprintingrecords;
local stringvar tempContacts="";
stringvar array ArrayContacts;
local numbervar j;
numbervar Contactscounter;

for j := 1 to (Contactscounter)
do
(
tempContacts := tempContacts + ArrayContacts[j] + chr(13) + Chr(10) + chr(13) + Chr(10);

);

tempContacts;
 
You can slice up fields using the Mid command. Best done in a formula field rather than a variable.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top