Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to justify text lines
Message
From
19/01/2005 20:26:51
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Title:
How to justify text lines
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
00978745
Message ID:
00978745
Views:
64
Hello,

I need to justify a string in a way similar to a phonebook. Name goes on left side and telephone number goes on the right. Spaces or perhaps "..." go in the middle. The parameters are: textbox width in inches, as indicated by property sheet of reporter, fontname, and fontsize.

I've used this code, but it doesn't work.
PROCEDURE JustifyLine
LPARAMETERS tcText
  lnBarPos = AT('|',tcText)
  IF lnBarPos = 0
    RETURN tcText
  ENDIF
  lnLineWidth  = gnLineWidthInches * 96  && ???
  lnFontWidth  = FONTMETRIC(6,gcFontName,gnFontSize)
  lnSpaceWidth = TXTWIDTH(SPACE(10),gcFontName,gnFontSize) * lnFontWidth / 10
  lcLeft       = ALLTRIM(LEFT(tcText,lnBarPos - 1))
  lnLeftWidth  = TXTWIDTH(lcLeft,gcFontName, gnFontSize) * lnFontWidth
  lcRight      = ALLTRIM(SUBSTR(tcText,lnBarPos + 1))
  lnRightWidth = TXTWIDTH(lcRight,gcFontName, gnFontSize) * lnFontWidth
  lnMidWidth   = lnLineWidth - lnLeftWidth - lnRightWidth
  lcMid        = SPACE(lnMidWidth/3.78)  && The magic number 3.78 is the closest I've got
  tcText       = lcLeft + lcMid + lcRight
RETURN tcText
Thanbk you for the help.

Alex
Next
Reply
Map
View

Click here to load this message in the networking platform