Programmatically Copying Text to/from Windows Clipboard

This article was previously published under Q108824
This article has been archived. It is offered "as is" and will no longer be updated.
SUMMARY
In FoxPro for Windows, the system memory variable _CLIPTEXT provides accessto the Windows system Clipboard for transferring text data (not graphics).
MORE INFORMATION
In FoxPro for MS-DOS, copying or cutting text places that text in aninternal clipboard used only by FoxPro for MS-DOS. In Windows-basedapplications, including FoxPro for Windows, copying or cutting an itemplaces that item in the Windows Clipboard, which is available to otherWindows applications.

To view the contents of the Windows Clipboard, open the Main group inProgram Manager, and in Windows 3.0 and 3.1, start Clipboard or in Windowsfor Workgroups 3.1 and 3.11, start Clipbook Viewer (which containsClipboard). Note, however, that Clipboard does not need to be running fordata to be stored in it.

NOTE: You can pass only text data using _CLIPTEXT, although the WindowsClipboard can store graphics as well as text.

Example of Copying Text from FoxPro to Notepad

  1. Start FoxPro for Windows.
  2. Type the following command in the Command window:
    _CLIPTEXT = "Text from FoxPro"
  3. Minimize or quit FoxPro.
  4. Start the Windows Notepad program (usually found in the Accessories group).
  5. From the Edit menu, choose Paste.
Notepad now contains the following line:
Text from FoxPro

Example of Copying Text From Memo Field to Clipboard

USE <table_name> && Open a database that contains a memo field
SCATTER MEMVAR MEMO
_CLIPTEXT=m.<memo_field_name> && Copy memo contents to clipboard

Example of Copying Text from Notepad to FoxPro

  1. Start Notepad.
  2. Type the following line in Notepad:
    Text from Notepad
  3. Select the line of text (so that it is highlighted).
  4. From the Edit menu, choose Copy.
  5. Minimize or quit Notepad.
  6. Start FoxPro for Windows.
  7. Type the following command in the Command window:
    ? _CLIPTEXT
The following is displayed on the FoxPro Desktop:
Text from Notepad
(c) Microsoft Corporation 2000, All Rights Reserved. Contributions by Kevin Zollman, Microsoft Corporation.

VFoxWin FoxWin 2.50 clipbrd.exe akz
Properties

Article ID: 108824 - Last Review: 12/04/2015 09:52:16 - Revision: 2.1

Microsoft Visual FoxPro 3.0 Standard Edition, Microsoft FoxPro 2.5b, Microsoft FoxPro 2.5a, Microsoft FoxPro 2.5b

  • kbnosurvey kbarchive KB108824
Feedback