Partilhar via


WCOLS( ) Function

Returns the number of columns within the active or specified window.

WCOLS([WindowName])

Return Values

Numeric

Parameters

  • WindowName
    Specifies the window for which WCOLS( ) returns the number of columns. In Visual FoxPro, you can also specify the name of a toolbar. If you don't specify a window, the number of columns in the active output window is returned. If no window is active, WCOLS( ) returns the number of columns in the main Visual FoxPro window.

    You can specify the name of a system window (the Command window, the Data Session window, a Browse window, and so on) in WCOLS( ) if the system window has been activated and is visible or hidden. In Visual FoxPro, you can specify the name of a toolbar (the Standard toolbar, the Color Palette toolbar, and so on) in WCOLS( ) if the toolbar has been activated and is visible or hidden. If you specify the name of a system window or toolbar that has not been activated, Visual FoxPro generates an error message. The Debug window is an exception. Once the Debug window has been opened, its name can be included in WCOLS( ) if it is visible, hidden or closed.

    You can also include the empty string as the window name to return the number of columns in the main Visual FoxPro window.

    The empty string can be used to specify the main Visual FoxPro window in functions such as WLCOL( ), WLROW( ), and WROWS( ), which return window locations or sizes.

Remarks

In Visual FoxPro, the value returned by WCOLS( ) depends on the font specified for the window. Many fonts can be displayed in a wide variety of sizes, and some are proportionally spaced. A column corresponds to the average width of a letter in the current font. For more information, see the Fonts Overview topic.

Example

The following example centers a short output message in the last row of a window of unknown size.

CLEAR
DO SendMesg WITH 'Message', WCOLS( ), WROWS( ) –1

*** SendMesg ***

PROCEDURE SendMesg
PARAMETERS gcMsg, gnCol, gnRow
STORE (gnCol – LEN(gcMsg))/2 TO gnCol
@ gnRow, gnCol SAY gcMsg
RETURN

See Also

SCOLS( ) | SROWS( ) | WLCOL( ) | WLROW( ) | WROWS( ) | Fonts Overview