Logo

Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.

SET CPCOMPILE, Set(“CPCompile”), SET CPDIALOG, Set(“CPDialog”)

The first of these commands determines the code page with which each compiled fragment of an application is marked. The second command specifies whether a confirmation dialog should be displayed whenever a table not marked with a code page is opened exclusively.

Usage

SET CPCompile TO [ nCodePage ]
nCodePage = SET(  "CPCompile")
SET CPDialog ON | OFF
cOnOrOff = SET( "CPDialog" )

By default, compiled elements of an application—programs, forms, and classes—are flagged with the current code page. Use this setting to override that marking. An element can still be flagged with its own code page by using the AS clause of the COMPILE command.

When a table is opened, Visual FoxPro reads the file’s header to determine which code page the data needs to be represented in. (See “DBF, FPT, CDX, DBC—Hike!” for details.) If the code page flag is blank, and the file is opened exclusively (so Visual FoxPro can write to the file header), the GETCP() dialog appears, asking you to choose the original code page of the file. You probably want to have this dialog appear during development, and might need it as part of an import routine, but we would typically leave this setting OFF in most of our applications. The CPZero.PRG utility, included with every version of Visual FoxPro, in the HOME() + “\Tools\CPZero" subdirectory, shows how you can blank out or update any table with its proper code page flag.

Example

cCPDialog = SET("CPDialog")  && preserve the setting
* do some processing here
SET CPDIALOG &cCPDialog      && restore the setting here

See Also

Compile, CPConvert(), CPCurrent(), CPDBF(), GetCP()