Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to justify text lines
Message
De
19/01/2005 20:26:51
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire de rapports & Rapports
Titre:
How to justify text lines
Versions des environnements
Visual FoxPro:
VFP 9
Divers
Thread ID:
00978745
Message ID:
00978745
Vues:
66
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform