Solved

FoxPro Padding

Posted on 2013-10-31
5
541 Views
Last Modified: 2013-11-01
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
Comment
Question by:smithmrk
  • 2
  • 2
5 Comments
 
LVL 16

Accepted Solution

by:
Kalpesh Chhatrala earned 500 total points
ID: 39614707
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
 
LVL 41

Expert Comment

by:pcelba
ID: 39614712
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
 

Author Closing Comment

by:smithmrk
ID: 39614715
OK, Thanks!
0
 

Author Comment

by:smithmrk
ID: 39616541
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
 
LVL 41

Expert Comment

by:pcelba
ID: 39616560
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
Data breaches are on the rise, and companies are preparing by boosting their cybersecurity budgets. According to the Cybersecurity Market Report (http://www.cybersecurityventures.com/cybersecurity-market-report), worldwide spending on cybersecurity …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question