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

Right padding text fields with characters

Status
Not open for further replies.

dukeslater

Technical User
Jan 16, 2001
87
US
I need to right pad some text fields with periods so that they all line up:

1. Were you treated promptly? ...........
2. Were you treated professionally? .....

I first tried using a loop that referenced the field length, but then realized that would only work with monospaced fonts.

Does anyone have a clever solution for this, or does Crystal have some functionality that I'm missing?

Thanks,

Duke
 
I think you'll end up using a trick:

1) Create a Text Object only consisting of periods.
2) Put that one the report
3) Put the reporting field on top of it (you might have to put it a little more to the right, otherwise it will be embedded into the text object).
4) Set the background of this field to white

Do the same for all other fields

GdB

 
Oops!

I'm wrong in right and left again. I should have written that you might have to put the reporting field a little more to the left.

GdB



 
Write a couple of formulas:

1) @tretated
"Were you treated Professionally?"

2)@TreatedQuestion
{@Treated}&ReplicateString(".",30-length({@Treated})

Reeat for the other questions, and replace the 30 with your desired length. This will solve your problem.

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports
 
If you are using a proportional font, then you could add the field to your details section and then just add a formula like dgillz suggests:

replicatestring(".",30-len({table.field}))

Format this to be right justified and then place it next to the first field as close as possible, without overlaps. This will cause some minor variation in the white space before the dots appear, but the right side will be aligned.

-LB

 
There's a better way, but I guess I just had to sleep on it.

Use the replicate string function, but add a value that far exceeds the width of the field:

{field name} + replicatestring(" .",200)

That way the extra periods are truncated and they all line up perfectly no matter which font is used.

Thanks as always!
 
Check that - they line up almost perfectly, but close enough....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top