次の方法で共有


GETCP( ) Function

Prompts for a code page by displaying the Code Page dialog box, and then returns the number of the code page chosen.

GETCP([nCodePage] [, cText] [, cDialogTitle])

Return Values

Numeric

Parameters

  • nCodePage
    Specifies the number of the code page that is initially selected when the Code Page dialog box is displayed. If nCodePage is 0 or if you omit nCodePage, a code page isn't selected when the Code Page dialog box is displayed.
  • cText
    Specifies the text displayed in the Code Page dialog box. If you omit cText, Visual FoxPro displays the following text: "Please select a code page for cross-platform data sharing."
  • cDialogTitle
    Specifies the title that appears in the Code Page dialog box title bar. If you omit cDialogTitle, the title "Code Page" is displayed.

Remarks

GETCP( ) returns 0 if you exit the Code Page dialog box by pressing ESC, choosing the Cancel button, or choosing Close from the Control menu.

The code pages listed in the Code Page dialog box are determined by FOXPRO.INT, the Visual FoxPro International code page support file.

You can include GETCP( ) in commands such as MODIFY COMMAND, APPEND FROM, and COPY TO that support the AS nCodePage clause. The Code Page dialog box is displayed, making it possible for you to specify the code page of the file opened, appended, or created. Because no code page 0 exists, you must trap for 0 in case the user chooses ESC, the Cancel button, or Close from the Control menu.

Example

The following example displays the Code Page dialog box with code page 1252 (Windows ANSI) selected. "Select a Code Page" is displayed as the caption in the Code Page dialog box, and "Code Page Selection" is displayed in the Code Page dialog box title bar.

? GETCP(1252, "Select a Code Page", "Code Page Selection")

See Also

APPEND FROM | COPY TO | EXPORT | IMPORT | MODIFY COMMAND | MODIFY FILE | MODIFY QUERY