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

Column Fomatting

Status
Not open for further replies.

psamedy

Technical User
Apr 22, 2002
60
US
I'm trying to implement the Replicatestring function in my formula, but have not been successful. I'd like to make the data that is returned to look like they are in column format and return to the next line after the third "column". The built in column formatting option available in the detail section will not work for me. Presently, my data is being returned in somewhat of a column format but i need the columns to line up correctly - straight. This is being used in the body of a form letter, and the variable is reset int the group header. After multiple posts the formula bellow is the closest i've been. Any help or any new ideas would be appreciated.

WhileprintingRecords;
StringVar Item := {provider.ppo_description};
StringVar Chain;
NumberVar ChCnt:=ChCnt+1;

if length(Chain) + Length(Item) > 254
then Chain := Chain
else if chcnt/3 = int(chcnt/3) then
Chain := chain+', '+Item+chr(13)
else if chcnt/3 <> int(chcnt/3) then
Chain := chain+' '+Item

This an exampe of what my data looks like:

ID Name Addr1 State ppo_description
-- ---- ----- ----- ----------------
01 Pat Ave A NY Local 2
01 Pat Ave A NY Local 4
01 Pat Ave A NY Local 5
03 Jane Ave B NY Local 1
03 Jane Ave B NY Local 15
02 Carl Ave J PA Local 7

I'd Like it to look like this in the form letter:

Local 2 Local 5 Local 7
Local 4 Local 15 Local 9
Local 1 Local 14 Local 3
 

I'm currently using a non-proportional font (courier), any other suggestions? i've been trying to solve this for weeks. Thanks pat
 
the best way is to assign each column to a different string variable array.

this can be done in one formula...once the arrays have been filled then they are displayed in separate Display formulas....this works well...I do this a lot.

If this sounds good to you I'll help you

Jim Broadbent
 
Jim, i'm at the point where almost anything will sound good. If a string variable array will work please lead me into the light!! Thanks
 
ok...here we go

the results will be printed in a footer is that ok??

Jim Broadbent
 
I don't understand the grouping here

******************
01 Pat Ave A NY Local 2
01 Pat Ave A NY Local 4
01 Pat Ave A NY Local 5
03 Jane Ave B NY Local 1
03 Jane Ave B NY Local 15
02 Carl Ave J PA Local 7

I'd Like it to look like this in the form letter:

Local 2 Local 5 Local 7
Local 4 Local 15 Local 9
Local 1 Local 14 Local 3

*****************

Don't you want ??

01 Pat Ave A NY Local 2 Local 4 Local 5





Jim Broadbent
 
Yes, What i have now is form letter that prints something like like this:

Pat 01
Ave A, NY

Dear Pat:

Local 2 Local 4 Local 5
 
ok....I just didn't understand this

Local 2 Local 5 Local 7
Local 4 Local 15 Local 9
Local 1 Local 14 Local 3

**************

Ok if we want the out put to look like this

01 Pat Ave A NY Local 2 Local 4 Local 5

How many columns of &quot;locals&quot; do we want here or do we want it to line up this way
*******************************
Pat 01
Ave A, NY

Dear Pat:

Local 2 Local 4 Local 5

*******************************

with a neater edge for the Local columns....again the question is how many Locals do you want across the page?



Jim Broadbent
 
i would like three locals across the page.
 
ok...this is pretty simple then

You are grouped by You probably don't need all these as groups but your report should have Groups 1 and 5 with the reset of the data sorted this way

Group 1 ID
Group 2 Name
Group 3 Addr1
Group 4 State
Group 5 ppo_description

In the Group 1 header you place the initialization formula

@initialization (supressed)

WhilePrintingRecords;

if not inRepeatedGroupHeader then
(
//initialize to 50% more locals than you expect to see for one ID
StringVar array Locals := [&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,....&quot;&quot;,&quot;&quot;];
NumberVar Pointer := 0;
);

Now in the Detail Section...suppressed place the following formula

@CollectLocals

WhilePrintingRecords;

StringVar array Locals ;
NumberVar Pointer ;

Pointer := Pointer + 1;
Locals[Pointer] := {provider.ppo_description};


Now comes the time to display the results....this is done in the Group 1 footer

You will need at least 3 display formulas

It depends on if the string(s) we will create will exceed 254 characters

I will assume they will...then you must divide your footer into (A) and (B) sections and you will have a total of 6 formulas

@DisplayLocal_1A

WhilePrintingRecords;
StringVar array Locals ;
NumberVar SubPointer1 ;
Result1 := &quot;&quot;;
OverFlag := 0;

For SubPointer1 := 1 to Ubound(Locals) step 3 do
(
If length(Result1 + Locals[Subpointer1]) > 254 then
Overflag := 1
else
Result1 := Result1 + Locals[Subpointer1] + chr(13) + chr(10);
if Overflag = 1 then exit do;
);

Result1;

For the formula in Footer B right below it

@DisplayLocal_1B

WhilePrintingRecords;
StringVar array Locals ;
NumberVar SubPointer1 ;
NumberVar newPointer;
Result1b := &quot;&quot;;

For newPointer := SubPointer1 to Ubound(Locals) step 3 do
(
Result1b := Result1b + Locals[newPointer] + chr(13) + chr(10);
);

Result1b;

We'll assume no overflow here

The other formula are similar

@DisplayLocal_2A

WhilePrintingRecords;
StringVar array Locals ;
NumberVar SubPointer2 ;
Result2 := &quot;&quot;;
OverFlag := 0;

For SubPointer2 := 2 to Ubound(Locals) step 3 do
(
If length(Result2 + Locals[Subpointer2]) > 254 then
Overflag := 1
else
Result2 := Result2 + Locals[Subpointer2] + chr(13) + chr(10);
if Overflag = 1 then exit do;
);

Result2 ;

NOTE THE START POINT FOR the For Next loop increases one

That should work fine


Jim Broadbent
 
Thanks Jim

I will try this, and let you know how it works! Thanks again

Pat
 
Hello Jim

With your first formula @initialization I get the following error message:

&quot;A string is expected here&quot;

and for @DisplayLocal_1A, @DisplayLocal_1B, @DisplayLocal_2A
I get the follwing message:

&quot;The remaining text does not appear to be part of the formula&quot;
 
@initialization (supressed)

WhilePrintingRecords;

if not inRepeatedGroupHeader then
(
//initialize to 50% more locals than you expect to see for one ID
StringVar array Locals := [&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,....&quot;&quot;,&quot;&quot;];
NumberVar Pointer := 0;
);

**************
StringVar array Locals := [&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,....&quot;&quot;,&quot;&quot;];

did you copy this eaxactly??? The &quot;....&quot; was not meant to be in the final formula...just meant that you add as many extra entries for Locals as you need in the same format as the others...I don't know how many you expect/group.

The other errors may be a result of the first formula not working...I cannot see anything wrong at the moment with them

OOPPPSSS.......

WhilePrintingRecords;
StringVar array Locals ;
NumberVar SubPointer2 ;
Result2 := &quot;&quot;;
OverFlag := 0;

For SubPointer2 := 2 to Ubound(Locals) step 3 do
(
If length(Result2 + Locals[Subpointer2]) > 254 then
Overflag := 1
else
Result2 := Result2 + Locals[Subpointer2] + chr(13) + chr(10);
if Overflag = 1 then Exit For;
);

Result2 ;

That should be EXIT FOR not EXIT DO...you will have to change in each formula...sorry about that



Jim Broadbent
 
Hello Jim

I'm getting following error with all the display formulas:
The remainig text does not appear to be part of the formula, and direct me to Numbervar Subpointer2;

WhilePrintingRecords;
StringVar array Locals ;
NumberVar SubPointer2 ;
Result2 := &quot;&quot;;
OverFlag := 0;

For SubPointer2 := 2 to Ubound(Locals) step 3 do
(
If length(Result2 + Locals[Subpointer2]) > 254 then
Overflag := 1
else
Result2 := Result2 + Locals[Subpointer2] + chr(13) + chr(10);
if Overflag = 1 then Exit For;
);

Result2 ;
 
Sorry...forgot to define the variables

WhilePrintingRecords;
StringVar array Locals ;
NumberVar SubPointer2 ;
StringVar Result2 := &quot;&quot;;
NumberVar OverFlag := 0;

For SubPointer2 := 2 to Ubound(Locals) step 3 do
(
If length(Result2 + Locals[Subpointer2]) > 254 then
Overflag := 1
else
Result2 := Result2 + Locals[Subpointer2] + chr(13) + chr(10);
if Overflag = 1 then Exit For;
);

Result2 ;


sorry about that


Jim Broadbent
 
Sorry Jim...

I'm getting another error message:

&quot;A number is required here&quot;

Result2 := Result2 + Locals[Subpointer2] + chr(13) + chr(10);

Pat
 
OK, I've just caught the end of this thread, but I have a different way of doing this.

I don't mean to add to any confusion/problems, so I won't be hurt if you don't use itand I apologise if I've misread your requirements.

Groups:

{provider.ID} (assuming this is unique)

A single formula :

If {provider.ID} <> NumberVar IDVar then
(StringVar SetVar := &quot;&quot;;
NumberVar Counter := 0);
Counter := Counter +1;
IDVar := {provider.ID};
StringVar LocalsVar := {provider.ppo_description}&Space(1);
If Counter = 3 then
(Counter := 0;
SetVar := SetVar&LocalsVar&chr(13);)
else
SetVar := SetVar&LocalsVar;

Place this in the {provider.ID} group footer.

Replace items in italics with actual field names.

Reebo
Scotland (Sunny with a Smile)
 
Ok I found the problem

WhilePrintingRecords;
StringVar array Locals ;
NumberVar SubPointer2 ;
StringVar Result2 := &quot;&quot;;
NumberVar OverFlag := 0;

For SubPointer2 := 2 to Ubound(Locals) step 3 do
(
If length(Result2 + Locals[Subpointer2]) > 254 then
(
Overflag := 1;
Result2 := Result2;
)

else
Result2 := Result2 + Locals[Subpointer2] + chr(13) + chr(10);
if Overflag = 1 then Exit For;
);

Result2 ;


Both halves of an if-then-else must be of the same data type....since OverFlag was a number it expected to see a number in the second half as well...

I THINK this will work now....thanks for your patience



Jim Broadbent
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top