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

spaces

Status
Not open for further replies.

needmoremoney

Technical User
Mar 30, 2005
123
US
I'm trying to put some spaces into a report. But it's not working. Inside a text field, I have some text and at the end of it, I would like to include 162 characters to the line.

This is what I have.
Formula
..... + replicatestring(" ", 162)

Any ideas, let me know. Thanks.
 
That formula makes no sense, perhaps you were trying to preserve space by not copying and pasting a few additional characters?

You can put spaces into a report by placing a text object and hitting the space bar and then dragging a field in front of it.

The formula you have, were it inside of a text field would simply produce those exact characters, so I'd guess that you're not really using a text field, perhaps you meant a string field.

Since CR 8.5 and below have limits of 254 or less for output formulas, if the field is long, this might present a problem too, hence another reason to post technical information rather than merely describing requirements with psuedo code.

Anyway, try using a formula and place:

{table.field} & replicatestring(" ",162)

Replace the {table.field} with your table.field, and don't use a text field, again, create a formula.

-k
 
Here's what I have:
.........
stringvar TotString:="";
TotString := "T4" + {@TotalEEs} + {@TotalSpaceFill} + Chr(013);
TotString;
...............

The code for @TotalSpaceFill is:
replicatestring(" ", 162)

My results is just just 13 spaces or so. I'd like to stretch the field to include 162 blank spaces. All the fields not including the @TotalSpaceFill takes up 13 spaces.

The result comes out into a text file.

Any help thanks.
 
Hmmm, looks like your truncating, but I'm not sure why, the formula seems OK, sorta...

Why not just use use (no variables, etc.):

"T4" & {@TotalEEs} & replicatestring(" ", 162) & Chr(13)

How do you know it's full length anyway?

Crystal doen't automatically expand the width of formula fields, you need to either right click it and select format field->Can Grow (which will allow it to expand vertically downward), or make it wide enough to show all of the data.

A common problem is that there isn't enough room on the report canvas. IF you are exporting the file only, then install the HP 3500CPS as a printer and base the report on this, which will allow for plenty of room.

If you still have difficulties, please post your software version in the next post.

A way to test the length would be:

len("T4" & {@TotalEEs} & replicatestring(" ", 162) & Chr(13)).

If that shows 13 or so...you have a bigger problem, but I think that understanding Crystal's nuances is the difficulty here.

-k
 
I'm using Crystal 8.5

I know the exact length because I open the text file and manually count the spaces.

The problem occurres when I open the text file, I could see the spaces at the end of each record but when I click on it, it places the cursor at the end of the file. When the file is scanned by the vendors system, it registers that there is no spaces there.

I haven't try the tip above. I'll let you know what I get. Else, thanks much.
 
Hello,

No, it's still not working.
I have three records, one in the group, one in the Detail section and one in the group footer.
The one in the group footer is working but not the other two.

for example.. when I open my text file up the cursor is at the end of the last field and not the length of the field specs that I want.

ex:
Group header record
.... john doe 12341222<---- cursor is here

Detail Section
.... john doe 12341222 quit<---- cursor is here

Group footer
.... 19 employees 2005 <---- Curson is here

I need for all the records to have that same length of 175.
Only the group footer works. I used the formulas in the previous post.

Any help thanks.
 
Please post the formulas you've used.

My formula makes sense, and you seem to grasp the replicatestring function just fine, so where is the difficulty?

If they're all to be a certain length, then you need to test for the length of everything else and add in the number of spaces required, as in:

numbervar SpaceNeeded:= 175(-len({table.field1})+len({table.field2}))
{table.field1}&{table.field1}&SpaceNeeded would add the right number of spaces to allow for the length of 175 per mine once you subtract the number of existing characters.

-k
 
Here are all of my formulas:

Group Header:
@DispHeader

Details:
@DispRecord

Footer:
@DispTotal

............
Then I have
@DispHeader is

stringvar dispstring:= "";
dispstring := "E4" + {@Fein} + {@StateAccount} + {@BranchCode} + {@ERName} + {@ERAddress} + {@ERCity} + {@ERState} + {@ERZip} + {@ERZipExt} + replicatestring("X",32) & Chr(143);
dispstring;

and
@DispRecord is

stringvar dispdetailrec:= "";
dispdetailrec := "W4" + {@EESSN} + {@EEFirst} + {@EEMiddle} + {@EELast} + {@EEAddress} + {@EECity} + {@EEState} + {@EEZip} + {@EEZipExt} + {@EEHireDate} + replicatestring("X",033) & Chr(142);
dispdetailrec;

and last
@DispTotal is

stringvar TotString:="";
TotString := "T4" + {@TotalEEs} + replicatestring(" ", 162) & Chr(13);
TotString;

...........

The problem is that the export text file does not see the header and detail spaces at the end. The group footer records includes the spaces but the group header and detail don't show the spaces. All lines should be 175 in length.

 
By the way, I have the X inside the replicatestring just for testing. I need to take those out.
 
Interesting, as I tested in CR 9 and the first two formulas work, but the group footer does not.

In my export, the replication of X's is fine, but apprently the export trims spaces.

As a workaround I would suggest that you use a character seperated export (seperated values(csv)), and use nothing as both the character seperator and the delimiter (jsut bacspace over the defaults).

This seemed to work OK for me using CR 9.

The text export is expecting a blurb of text I think and the DLL gets confused about spaces.

-k
 
Hello synapsevampire,

Thanks for all your help. I tried CSV before, but it just returns jumbled text. After one and almost half a packs of cigarrettes today, I'm giving up.

I'm just gonna start from scatch. I've been working on this for a few days now. No luck at all. There's something wrong that I can't figure out. Maybe something that I did from the start.

Maybe recoding everything from scratch will do it.

I'll probably generate some SQL statements to create one temp table that will be easier to work with also. Maybe that will eliminate any table linking problems.

Thanks again. Much obliged. [pipe]
 
Yes, I have tried that. I've tried space(161) and even just manually inputting spaces like " " into a formula. Still no luck.

Funny thing though. Now my group footer doesn't input the spaces anymore. The spaces are there, but when I click on the line where the record sits, the cursor falls on the space of the last entry and not not the last space of the line, which is suppose to be 175.

Thanks much for all the help. I'm gonna digest it a bit more then start over.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top