JavaScript Editor js editor     Web development 



Main Page

Returns the length of a character expression with respect to the average character width for a font.

TXTWIDTH(cExpression [, cFontName, nFontSize [, cFontStyle]])

Parameters

cExpression


Specifies a character expression for which TXTWIDTH(В ) returns the length. If you include only cExpression, the length of the character expression is returned for the current font for the main Visual FoxPro window or the active output window. A non-proportional font always returns a value equal to the number of characters in cExpression. Include the optional arguments cFontName, nFontSize and cFontStyle to determine the length of a character expression with a specific font, font point size, or font style.
cFontName


Specifies the name of the font. Include cFontName to return the length of a character expression with a specific font.
nFontSize


Specifies a number that corresponds to the point size of the font. Include nFontSize to return the length of a character expression with a specific point size.
cFontStyle


Specifies a special font style for the character expression. cFontStyle is a font style code specified by a character or a set of characters. The Normal font style is used if cFontStyle isn't included. Here are the characters for each font style:

Character Font Style

B

Bold

I

Italic

N

Normal

O

Outline

Q

Opaque

S

Shadow

-

Strikeout

T

Transparent

U

Underline

You can include more than one character to specify a combination of font styles. For example, BI specifies a Bold Italic font style. The following command displays a message in a Courier normal 24-point font, centered horizontally in the main Visual FoxPro window:
В Copy Code
@ 25,(WCOLS( )-TXTWIDTH('Hello!','Courier ',24)* ;
   FONTMETRIC(6,'Courier ',24)/FONTMETRIC(6))/2  ;
   SAY 'Hello!' FONT 'Courier ',24

Return Value

Numeric

Remarks

TXTWIDTH(В ) returns the number of characters a character expression cExpression occupies, based on the average character width of a specified font (the average character width of a font is called a foxel). Use FONTMETRIC(6) to determine the average character width of a font.

If you don't include a font in TXTWIDTH(В ), the value returned by TXTWIDTH(В ) is determined by the current font for the main Visual FoxPro window, as long as output is directed to the main Visual FoxPro window when TXTWIDTH(В ) is issued. If output is being directed to a user-defined window, the value returned is determined by the window's current font.

See Also



JavaScript Editor js editor     Web development 
R7