Test clipboard

4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next

version 6.0


Test clipboard (dataType) Number

ParameterTypeDescription
dataTypeString4-character data type string
Function resultNumberSize (in bytes) of data stored in Clipboard
or error code result

Description

The Test clipboard command allows you to test if there is data of the type you passed in dataType present in the Clipboard.

WARNING: The value you pass in dataType is case sensitive, i.e., "abcd" is not equal to "ABCD."

If the Clipboard is empty or does not contain any data of the specified type, the command returns an error -102 (see the table of predefined constants). If the Clipboard contains data of the specified type, the command returns the size of this data, expressed in bytes.

After you have detected that the Clipboard contains data of the type in which you are interested, you can extract that data from the Clipboard using one the following commands:

If the Clipboard contains type TEXT data, you can obtain that data using the Get text from clipboard command, which returns a text value, or the GET CLIPBOARD command, which returns the text into a BLOB.

If the Clipboard contains type PICT data, you can obtain that data using the GET PICTURE FROM CLIPBOARD command, which returns the picture into a picture field or variable, or the GET CLIPBOARD command, which returns the picture into a BLOB.

For any other data type, use the GET CLIPBOARD command, which returns the data into a BLOB.

4th Dimension provides the following predefined constants:

ConstantTypeValue
No such data in clipboardLong Integer-102
Text dataStringTEXT
Picture dataStringPICT

Examples

1. The following code tests whether the Clipboard contains a picture and, if so, copies that picture into a 4D variable:

   If (Test clipboard (Picture data) > 0)  ` Is there a picture in the clipboard?
      GET PICTURE FROM CLIPBOARD ($vPicVariable)  ` If so, extract the picture from the clipboard
   Else
      ALERT("There is no picture in the clipboard.")
   End if

2. Usually, applications cut and copy data of type TEXT or PICT into the Clipboard, because most applications recognize two standard data types. However, an application can append to the Clipboard several instances of the same data in different formats. For example, each time you cut or copy a part of a spreadsheet, the spreadsheet application could append the data under the hypothetical 'SPSH' format, as well as in SYLK and TEXT formats. The 'SPSH' instance would contain the data formatted using the application's data structure. The SYLK form would contain the same data, but using the SYLK format recognized by most of the other spreadsheet programs. Finally, the TEXT format would contain the same data, without the extra information included in the SYLK or the hypothetical 'SPSH' format. At this point, while writing Cut/Copy/Paste routines between 4th Dimension and that hypothetical spreadsheet application, assuming you know the description of the 'SPSH' format and that you are ready to parse SYLK data, you could write something like:

   Case of
         ` First, check whether the clipboard contains data from the hypothetical spreadsheet application
      : (Test clipboard ('SPSH') > 0)
         ` ...
         ` Second, check whether the clipboard contains Sylk data
      : (Test clipboard ('SYLK') > 0)
         ` ...
         ` Finally check whether the clipboard contains Text data
      : (Test clipboard ('TEXT') > 0)
         ` ...
   End case

In other words, you try to extract from the Clipboard the instance of the data that carries most of the original information.

3. See the example for the APPEND TO CLIPBOARD command.

See Also

GET CLIPBOARD, GET PICTURE FROM CLIPBOARD, Get text from clipboard.


4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next