• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 579
  • Last Modified:

FoxPro Padding

Good afternoon Experts!

OK, this seems simple, yet I'm stuck!
In my form I have a set of fields that I'm tring to create a column in the Details Section like this:

PADR('Company Name',18," ") + ':'
PADR('Company ID',18," ") + ':'
PADR('Company Code',18," ") + ':'

So that all my columns the : line up.

But they are not lining up?  Why?

Thanks,
Mark
0
smithmrk
Asked:
smithmrk
  • 2
  • 2
1 Solution
 
Kalpesh ChhatralaSoftware ConsultantCommented:
you need to modify code like below

PADR('Company Name',18," ") + ":"
PADR('Company ID',20," ") + ':'      && 2 Character is less so we need to add padding more
PADR('Company Code',18," ") + ':'

It's Font related Issue because each character width is not same in font like arial,Times New Roman,Verdana,Tahoma,etc.

if you use "Courier New" Font in your Label Caption then this problem will resolved.
0
 
pcelbaCommented:
You have to use non-proportional font, e.g. CourierNew to line up single texts.

Other options are:
1) Display the colon in separate column
2) Calculate the real text length using TXTWIDTH() and add variable number of spaces - this will not adjust all texts 100% accurately but possible deviation is about 1/3 of character.
0
 
smithmrkAuthor Commented:
OK, Thanks!
0
 
smithmrkAuthor Commented:
I appreciate the additional comments pcelba, I had already given the points to kalpesh2804 before I saw your comment.

FYI...I changed the Font to Courier New...however I did like the idea of the TXTWIDTH(), which I may try when I find time, but for now it just seemed easier to change the font.

Thanks to BOTH of you!

Mark
0
 
pcelbaCommented:
It is OK, Kalpesh needs points more than me :-)

BTW, I would go the way of two separate fields. You may display left justified texts in one field/label and  colons in another field/label. It will be easy to design and independent on the text length.

TXTWIDTH() is useful if nothing else helps.

P.C.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now