PRB: _CLIPTEXT Loses Line Feeds (ASCII 10) (268478)



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 6.0

This article was previously published under Q268478

SYMPTOMS

When accessing information that is pasted to the Windows Clipboard through the _CLIPTEXT system variable, line feed (ASCII 10) characters are removed. Also, when assigning a value to the _CLIPTEXT system variable, line feed characters converted to carriage return (ASCII 13) characters.

CAUSE

Visual FoxPro is expecting carriage returns (ASCII 13) to be used for end-of-row or end-of-line terminators and, therefore, replaces lines feeds (ASCII 10) with carriage returns (ASCII 13) when assigning a value to the _CLIPTEXT system variable.

NOTE: No other ASCII characters are affected in this manner.

RESOLUTION

When access to the original text pasted in the Clipboard is required and the loss of line feeds causes problems, you may retrieve the same information through the FoxTools Library GETCLIPDAT() function, as follows:
Local lcClipText
Set Library To (Home()+"FoxTools.Fll")
If OpenClip(0)
    lcClipText = GetClipDat(1)
    CloseClip()
Else
    lcClipText = Space(0)
Endif
				

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a program file called MAKE_IT.prg, paste the following code into the program, and then run the program:
    lnHandle = FCreate("Test.txt",0)
    =FWrite(lnHandle,"Line 1" + CHR(9) + "2" + CHR(9) + "3" + CHR(9) + "4" + CHR(10))
    =FWrite(lnHandle,"Line 2" + CHR(9) + "6" + CHR(9) + "7" + CHR(9) + "8" + CHR(10))
    =FWrite(lnHandle,"Line 3" + CHR(9) + "10" + CHR(9) + "11" + CHR(9) + "12" + CHR(10))
    =FFlush(lnHandle)
    =FClose(lnHandle)
    					
  2. Create a program file called TEST_IT.prg, paste the following code into the program, and then save the program.

    NOTE: Do not run this program until the next step has been completed.
    Set Library To (Home()+"FoxTools.Fll")
    If OpenClip(0)
        y = GetClipDat(1)
        ? "From GetClipDat: ", y
        ? "From _ClipText: ", _ClipText
        ? "GetClipDat = _ClipText: ", (y=_ClipText)
        CloseClip()
    Endif
    Set Library To
    					
  3. Open file named TEST.txt (created by the program in step 1) in Notepad, select all of the text, and then copy it to the Clipboard.
  4. In the Command window, enter the following command:
    DO TEST_IT.prg
  5. Observe the output from the second program:
    • Data From GetClipDat - observe that a new line is started after the 4 and the 8.

    • Data From _ClipText - observe that '4Line 2' and '8Line 3' run together.

    • GetClipDat = _ClipText returns .F. (false), indicating that the values from GetClipDat() and _ClipText are not the same.

REFERENCES

For additional information about the FoxTools Library, please refer to the Help file located where you have Visual FoxPro installed, in the Tools folder. The Help file name is FOXTOOLS.CHM.

Modification Type:MajorLast Reviewed:8/9/2000
Keywords:kbCodeSnippet kbDSupport kbprb kbXBase KB268478 kbAudDeveloper