Microsoft KB Archive/220835

= How To Change the Code Page of Project Files =

Article ID: 220835

Article Last Modified on 6/29/2004

-

APPLIES TO


 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q220835



SUMMARY
This article describes how you can change the code page settings of forms, reports, labels, class libraries, database containers, and text files in a project.



MORE INFORMATION
To change the code page of forms, reports, labels, database containers, and class libraries in a project, do the following:  Open the project in which you want to change the code page. If the project is under source code control, right-click the form, report, label, or class library whose code page you want to change. From the Shortcut menu, select Check Out, and then click OK.  Use Cpzero.prg to change the code page of the file. To change the code page of c:\MyProj\Forms\MyForm.SCX to 1252, run Cpzero.prg as follows: DO cpzero WITH "c:\MyProj\Forms\MyForm.scx",1252 NOTE: For a database container (.dbc) file you need to close the project and the .dbc file before running Cpzero.prg.  If the project is under source code control, in the Project Manager, right-click on the file that was checked out in step 2. From the Shortcut menu, select Check In, and then click OK in the Check In Files dialog box. From the Project menu, select Project Info, and then select the Files tab in the Project Information dialog box. Note that the code page for the file does not appear to have changed. To display the latest code page, click the Update Native Code Pages button. Click OK to close the Project Information dialog box.</li> If the project is under source code control, do the following in order for other users to see the new code page: <ul> From the Project->Source Control menu, select the Update Project List option to update the original project.</li> For other users to view the new code page, they must choose Update Project List, and then select the Update Native Code Pages from the Files tab of the Project Information dialog box.</li></ul> </li></ol>

To change the code page of text files, such as program (*.prg) files, in a project under source code control, do the following:
 * 1) Open the project in which you want to change the code page. From the project menu, select Project Information.
 * 2) Select the Files tab. Right-click on the text file, for example MyProg.prg, and, from the Shortcut menu, select the Code Page option.
 * 3) From the Code Page dialog box, select the code page that you want, and then click the Select button.
 * 4) If the project is under source code control, then do the following to make the changes visible to other users:
 * 5) * In the Project Information dialog box, click on Update Native Code Pages, and then close the dialog box.
 * 6) * From the Project->Source Control menu, select the Update Project List option to update the main project. For other users to view the new code page, each user needs to select the Update Project List option.

The code page of a project can be updated programmatically by using the project object. You can run the following sample code to do this.

WARNING: While you can programmatically change the project using the following code, Microsoft does not recommend or support changes to the project in this manner. Please make sure to back up your files before attempting to modify your project. * Start of Code PARAMETERS ProjName, NewCdPg, FleExt fCnt=0  &&File Count **Open The Project MODIFY PROJECT (ProjName+".PJX") NOSHOW NOWAIT ** Get Project information oCurProj=_VFP.ACTIVEPROJECT ProjName = oCurProj.NAME **Place File Names of Requested Type in an array DIMENSION FleNmAry(oCurProj.FILES.COUNT) FOR i = 1 TO oCurProj.FILES.COUNT IF UPPER(RIGHT(oCurProj.FILES(i).NAME, 3)) = FleExt fCnt=fCnt+1 FleNmAry(fCnt)= oCurProj.FILES(i).NAME ENDIF ENDFOR **Close Project oCurProj.CLOSE **Open Project as a Table and UpDate Code Pages CLOSE ALL USE (ProjName+".PJX") EXCLUSIVE IN 0 SELECT (ProjName) FOR i = 1 TO fCnt UPDATE (ProjName) SET Cpid = NewCdPg; WHERE UPPER(JUSTFNAME(FleNmAry(i))) = UPPER(JUSTFNAME(NAME)) ENDFOR **Close Project, opened as a Table USE IN (ProjName) MODI PROJ (ProjName) NOWAIT The preceding program sample can be called by using the following syntax: Do CpProj WITH "ProjectName", Code Page, "FileExtension" To change the code page of all the forms (SCX) to 1252 in a project named MyProj, use the following command: DO CpProj WITH "MyProj", 1252, "SCX" NOTE: The preceding program sample does not contain any error checking and assumes the following:
 * End of Code
 * Project is not open and not empty.
 * Project exists in the current directory/path.
 * All three parameters are passed.
 * Correct code page is specified.
 * ProjName and FleExt passed as character strings.
 * Code Page passed as numeric.

<div class="references_section">