Language Enhancements

In the current release of Visual FoxPro, you will find enhanced functionality via new and enhanced commands and functions. Expand and collapse this topic to see information about miscellaneous language additions and improvements.

Class Enhancements

Visual FoxPro contains significant language enhancements for classes, forms, controls, and object-oriented related features. For more information, see Class Enhancements.

Data and XML Enhancements

Visual FoxPro contains significant language enhancements for Data, SQL and XML features. For more information, see SQL Language Improvements and Data and XML Feature Enhancements.

IDE Enhancements

Visual FoxPro contains a number of language enhancements for features related to the IDE (Interactive Development Environment). For more information, see Interactive Development Environment (IDE) Enhancements and Enhancements to Visual FoxPro Designers.

Printing and Reporting Enhancements

Visual FoxPro contains a number of language enhancements to support new Reporting functionality:

Additionally, there are improvements to the following related Printing language elements:

  • SYS(1037) - Page Setup Dialog Box

    Displays Visual FoxPro default or report Page Setup dialog box or sets printer settings for the default printer in Visual FoxPro or for the report printer environment. In this version, a new nValue parameter is available.

  • APRINTERS( ) Function

    Returns a five-column array with the name of the printer, connected port, driver, comment, and location. The last three columns are available if the new optional parameter is passed.

  • GETFONT( ) Function

    Contains an additional setting to display only those fonts available on the current default printer and clarified values for the language script.

New Reporting functionality is described in more detail in separate Reporting topics. For more information, see Guide to Reporting Improvements.

Specifying Arrays with More Than 65K Elements

You can now specify arrays containing more than 65,000 elements, for example, when using the DIMENSION command. Normal arrays and member arrays have a new limit of 2GB. Arrays containing member objects retain a limit of 65,000 elements.

Note

Array sizes can also be limited by available memory, which affects performance, especially for very large arrays. Make sure your computer has enough memory to accommodate the upper limits of your arrays.

The Library Construction Kit, which contains the files Pro_Ext.h, WinAPIMS.lib, and OcxAPI.lib, still has a limit of 65,000 elements. For more information about these files, see Accessing the Visual FoxPro API, How to: Add Visual FoxPro API Calls, and How to: Build and Debug Libraries and ActiveX Controls. The SAVE TO command does not support saving arrays larger than 65,000 elements.

For more information, see Visual FoxPro System Capacities and DIMENSION Command.

STACKSIZE Setting Increases Nesting Levels to 64k

For operations such as the DO command, you can change the default number of nesting levels from 128 levels to 32 and up to 64,000 levels of nesting by including the new STACKSIZE setting in a Visual FoxPro configuration file.

Note

You can change the nesting level only during Visual FoxPro startup.

For more information, see Special Terms for Configuration Files and Visual FoxPro System Capacities.

Program and Procedure File Size Is Unrestricted

In previous versions of Visual FoxPro, the size of a procedure or program could not exceed 65K. Visual FoxPro now removes this restriction for programs and procedures. For more information, see Visual FoxPro System Capacities.

PROGCACHE Configuration File Setting

In previous versions of Visual FoxPro, you could not specify the program cache size or amount of memory reserved to run programs. This configuration file setting allows you to control this. It is especially useful for MTDLL scenarios. For more information, see Special Terms for Configuration Files.

ICASE( ) Function

The new ICASE( ) function makes it possible for you to evaluate a list of conditions and return results depending on the result of evaluating those conditions. For more information, see ICASE( ) Function.

TTOC( ) Converts DateTime Expressions to XML DateTime Format

You can convert a DateTime expression into a character string in XML DateTime format by passing a new optional value of 3 to the TTOC( ) function. For more information, see TTOC( ) Function.

SET COVERAGE Command Available at Run Time

The SET COVERAGE command is now available at run time so that you can debug errors that occur at run time but not at design time. For more information, see SET COVERAGE Command.

CLEAR ERROR Command

The new ERROR clause for the CLEAR command makes it possible to reset the error structures as if no error occurred. This affects the following functions:

  • The AERROR( ) function will return 0.

  • The ERROR( ) function will return 0.

  • The output from MESSAGE( ), MESSAGE(1) and SYS(2018) will return a blank string.

The CLEAR command should not be used with the ERROR clause within a TRY...CATCH...FINALLY structure. For more information, see CLEAR Commands.

Write Options Dialog Settings to Registry Using SYS(3056)

The SYS(3056) function can now be used to write out settings from the Options dialog box to the registry.

SYS(3056 [, nValue ])

The following table lists values for nValue.

nValue Description

1

Update only from registry settings, with the exception of SET commands and file locations.

2

Write out settings to the registry.

For more information, see SYS(3056) - Read Registry Settings.

FOR EACH ... ENDFOR Command Preserves Object Types

Visual FoxPro now includes the FOXOBJECT keyword for the FOR EACH ... ENDFOR command to support preservation of native Visual FoxPro object types.

FOR EACH objectVar [AS Type [OF ClassLibrary ]] IN Group FOXOBJECT

Commands

[EXIT]

[LOOP]

ENDFOR | NEXT [Var]

The FOXOBJECT keyword specifies that the objectVar parameter created will be a Visual FoxPro object. The FOXOBJECT keyword only applies to collections where the collection is based on a native Visual FoxPro Collection class. Collections that are COM-based will not support the FOXOBJECT keyword.

For more information, see FOR EACH ... ENDFOR Command.

SET PATH Command Enhancements

The SET PATH command now supports the ADDITIVE keyword. The ADDITIVE keyword appends the specified path to the end of the current SET PATH list. If the path already exists in the SET PATH list, Visual FoxPro does not add it or change the order of the list. Paths specified with the ADDITIVE keyword must be strings in quotes or valid expressions.

In addition, the length of the SET PATH list has been increased to 4095 characters.

For more information, see SET PATH Command.

Trim Functions Control Which Characters Are Trimmed

It is now possible to specify which characters are trimmed from an expression when using the TRIM( ), LTRIM( ), RTRIM( ), and ALLTRIM( ) functions.

TRIM(cExpression[, nFlags] [, cParseChar [, cParseChar2 [, ...]]])

LTRIM(cExpression[, nFlags] [, cParseChar [, cParseChar2 [, ...]]])

RTRIM(cExpression[, nFlags] [, cParseChar [, cParseChar2 [, ...]]])

ALLTRIM(cExpression[, nFlags] [, cParseChar [, cParseChar2 [, ...]]])

You can specify that the trim is case-insensitive using the nFlag value of 0 bit and 1.

The cParseChar parameter specifies one or more character strings to be trimmed from cExpression. A maximum of 23 strings can be specified in cParseChar.

By default, if cParseChar is not specified, then leading and trailing spaces are trimmed from character strings or 0 bytes are removed for Varbinary data types.

The cParseChar parameters are applied in the order they are entered. When a match is found, cExpression is truncated and the process repeats from the first cParseChar parameter.

For more information, see the TRIM( ) Function, LTRIM( ) Function, RTRIM( ) Function, and ALLTRIM( ) Function topics.

ALINES( ) Offers More Flexible Parsing Options

The ALINES( ) function has been enhanced to provide several additional options such as case-insensitive parsing and improved handling of empty array elements. These options are available using the new nFlags parameter that replaces the older lTrim 3rd parameter. For more information, see ALINES( ) Function.

Improvements in TEXT…ENDTEXT Statement

You can use the TEXT…ENDTEXT command to eliminate line feeds using the new PRETEXT setting. A new FLAGS parameter controls additional output settings. For more information, see TEXT ... ENDTEXT Command.

Include Delimiters in STREXTRACT( ) Results

The STREXTRACT( ) function has a new nFlags setting that allows you to include the specified delimiters with the returned expression. For more information, see STREXTRACT( ) Function.

STRCONV( ) Enhanced to Allow for Code Page and FontCharSet

For certain conversion settings, you can specify an optional Code Page or Fontcharset setting for use in the conversion. For more information, see STRCONV( ) Function.

TYPE( ) Determines if an Expression is an Array

The TYPE( ) function accepts the parameter, 1, to evaluate an expression to determine if it is an array.

Type(cExpression, 1)

The following character values are returned if the 1 parameter is specified.

Return Value Description

A

cExpression is an array.

U

cExpression is not an array.

C

cExpression is a collection.

cExpression must be passed as a character string.

For more information, see TYPE( ) Function.

BINTOC( ) and CTOBIN( ) Have Additional Conversion Capabilities

The BINTOC( ) and CTOBIN( ) functions have update or new parameters that provide you with more control over the output of these functions. Additionally, these enhancements offer some improvements for working with Win32 API routines. For more information, see BINTOC( ) Function and CTOBIN( ) Function.

MROW( ) and MCOL( ) Can Detect the Position of the Mouse Pointer

The MROW( ) and MCOL( ) functions now have a zero (0) parameter for detecting the position of the mouse pointer based on the currently active form instead of the form returned by the WOUTPUT( ) function. Although they are typically reference the same form, if the AllowOutput property of the form is set to False (.F.), WOUTPUT( ) does not return the current active form. The mismatch of references and can lead to unexpected results. By using the zero (0) parameter, you can avoid misplacing items, such as Shortcut menus, as the currently active form is always used.

For more information, see MROW( ) Function and MCOL( ) Function.

INPUTBOX( ) Returns A Cancel Operation

The INPUTBOX( ) function contains an additional parameter that allows you to determine if the user canceled out of the dialog. For more information, see INPUTBOX( ) Function.

AGETCLASS( ) Supported for Runtime Applications

The AGETCLASS( ) fiunction is now supported for runtime applications. For more information, see AGETCLASS( ) Function.

SYS(2019) Extends Handling of Configuration Files

You can use SYS(2019) to obtain the name and location of both internal and external configuration files. For more information, see SYS(2019) - Configuration File Name and Location.

SYS(2910) Controls List Display Count

You can control the number of items that appear in a drop-down list such as the one used by AutoComplete Property. This is the setting that is available on the View Tab, Options Dialog Box of the Options Dialog Box (Visual FoxPro).

For more information, see SYS(2910) - List Display Count.

Visual FoxPro will display a tip such as "CTRL+Click to follow the link" when you hover over a hyperlink in the editor. If you desire to not have this tip show, you can use SYS(3008) to turn it off. This function is also useful for international applications where you do not want to display the English text for this tip. For more information, see SYS(3008) - Hyperlink Tooltips.

SYS(3065) Internal Program Cache

You can obtain the internal program cache (PROGCACHE configuration file setting). For more information, see SYS(3065) - Internal Program Cache.

SYS(3101) COM Code Page Translation

You can now specify a code page to use for character data translation involving COM interoperability. For more information, see SYS(3101) - COM Code Page Translation.

Bidirectional Support for Tooltips and Popups

For international applications that display text from right to left, you can use the following new enhancements to control text justification:

  • SYS(3009) - right justifies text in ToolTips.

  • DEFINE POPUP…RTLJUSTIFY - right justifies items in a popup, such as a shortcut menu.

  • SET SYSMENU TO RTLJUSTIFY - right justifies an entire menu system.

The SYS(3009) function is a global setting. For more information, see SYS(3009) - Bidirectional Text Justification for ToolTips, DEFINE POPUP Command and SET SYSMENU Command.

Enhanced Font Script Support

Visual FoxPro 9.0 contains a number of enhancements that extend ability to specify a Font Language Script (or FontCharSet) along with existing Font settings:

  • SYS(3007) - specifies a FontCharSet for ToolTips. This is a global setting.

  • FONT Clause - the following table lists commands that support an optional FONT clause that allows for specification of a FontCharSet in the following format:

    FONT cFontName [, nFontSize [, nFontCharSet]]

    Command

    DEFINE MENU

    DEFINE POPUP

    DEFINE BAR

    DEFINE PAD

    DEFINE WINDOW

    MODIFY WINDOW

    BROWSE/EDIT/CHANGE

    ?/??

  • Browse - the Font Dialog Box that you can invoke by selecting the Font menu item from the Table menu with a Browse Window active now allows for selection of a font language script. You can specify a global default font script from the IDE Tab, Options Dialog Box in the Options Dialog Box (Visual FoxPro). To do this, you must first check the Use font script checkbox.

  • Editors - the Font Dialog Box that you can invoke with an editor window active by selecting the Font menu item from the Format menu or right-click shortcut menu Edit Properties Dialog Box now allows for selection of a font language script. You can specify a global default font script from the IDE Tab, Options Dialog Box in the Options Dialog Box (Visual FoxPro). To do this, you must first check the Use font script checkbox.

For more information, see SYS(3007) - ToolTipText Property Font Language Script, IDE Tab, Options Dialog Box, and FontCharSet Property.

ToolTip Timeout Control

You can specify how long a ToolTip is displayed if the mouse pointer is left stationary. For more information, see _TOOLTIPTIMEOUT System Variable.

Tablet PC Features

The following features are available to assist with applications designed to run on a Tablet PC computer.

  • ISPEN( ) - determines if the last Visual FoxPro application mouse event on a Tablet PC was a pen tap.

  • _SCREEN.DisplayOrientation - this read-write property specifies the screen display orientation for a Tablet PC. The value returned is the current orientation.

  • _TOOLTIPTIMEOUT - specifies how long a ToolTip is displayed if the mouse pointer is left stationary.

For more information, see ISPEN( ) Function, DisplayOrientation Property, and _TOOLTIPTIMEOUT System Variable.

Windows Message Event Handling

Visual FoxPro allows you to trap and handle window messages from the Microsoft® Windows® operating system using existing BINDEVENT functions. Some examples of common events you might wish to trap for include:

  • A power broadcast message used to intercept standby or power-down activities.

  • Media insertion and removal events, such as the insertion of a CD into a drive.

  • The insertion and/or removal of a Plug and Play hard disk (e.g., USB Drive).

  • Interception of screen saver queries to stop the screen saver from activating.

  • Operating system level font changes and Windows XP Theme changes.

  • New network connections/shares added or removed from system.

  • Switching between applications.

You can use the Visual FoxPro BINDEVENT functions to register (and unregister) event handlers used to intercept messages (i.e., Win32 API window messages that get processed by the Win32 WindowProc function). See MSDN for more details.

The new BINDEVENT( ) syntax requires the hWnd (integer) of the window receiving the message you desire to intercept, and the specific message itself (integer). For example, power-management events such as standby and power-down use the Win32 WM_POWERBROADCAST message (value of 536).

BINDEVENT(hWnd, nMessage, oEventHandler, cDelegate)

The following example illustrates detection of a Windows XP Theme change:

#DEFINE WM_THEMECHANGED    0x031A
#DEFINE GWL_WNDPROC    (-4)
PUBLIC oHandler
oHandler=CREATEOBJECT("AppState")
BINDEVENT(_SCREEN.hWnd, WM_THEMECHANGED, oHandler, "HandleEvent")
MESSAGEBOX("Test by changing Themes.")
DEFINE CLASS AppState AS Custom
nOldProc=0
PROCEDURE Destroy
    UNBINDEVENT(_SCREEN.hWnd, WM_THEMECHANGED)
ENDPROC
PROCEDURE Init
    DECLARE integer GetWindowLong IN WIN32API ;
        integer hWnd, ;
        integer nIndex
    DECLARE integer CallWindowProc IN WIN32API ;
        integer lpPrevWndFunc, ;
        integer hWnd,integer Msg,;
        integer wParam,;
        integer lParam
    THIS.nOldProc=GetWindowLong(_VFP.HWnd,GWL_WNDPROC)
ENDPROC
PROCEDURE HandleEvent(hWnd as Integer, Msg as Integer, ;
    wParam as Integer, lParam as Integer)
    lResult=0
    IF msg=WM_THEMECHANGED
        MESSAGEBOX("Theme changed...")
    ENDIF
    lResult=CallWindowProc(this.nOldProc,hWnd,msg,wParam,lParam)
    RETURN lResult
ENDPROC
ENDDEFINE

The following SYS( ) functions are also available to assist with handing these events:

  • SYS(2325) - returns the hWnd of a client window from the parent window's WHANDLE.

  • SYS(2326) - returns a Visual FoxPro WHANDLE from a window’s hWnd.

  • SYS(2327) - returns a window's hWnd from a Visual FoxPro window’s WHANDLE.

For more information, see BINDEVENT( ) Function, UNBINDEVENTS( ) Function, and AEVENTS( ) Function. Also, see SYS(2325) - WCLIENTWINDOW from Visual FoxPro WHANDLE, SYS(2326) - WHANDLE from a Window's hWnd, and SYS(2327) - Window's hWnd from Visual FoxPro WHANDLE for related topics. Refer to MSDN as reference source for details on specific window messages.

See Also

Reference

Guide to Reporting Improvements
Data and XML Feature Enhancements
SQL Language Improvements
Class Enhancements
Interactive Development Environment (IDE) Enhancements
Enhancements to Visual FoxPro Designers
Miscellaneous Enhancements
Changes in Functionality for the Current Release

Other Resources

What's New in Visual FoxPro