SED navigation bar go to SED home page go to Dataplot home page go to NIST home page SED Home Page SED Staff SED Projects SED Products and Publications Search SED Pages
Dataplot Vol 1 Vol 2

CLIPBOARD

Name:
    READ CLIPBOARD
    READ STRING CLIPBOARD
    SET CLIPBOARD SKIP
    WRITE CLIPBOARD

    CLIPBOARD RUN
    CLIPBOARD PAUSE
    CLIPBOARD RESUME
    SET CLIPBOARD RUN CLEAR

    CLIPBOARD CLEAR
    LIST CLIPBOARD
    COPY CLIPBOARD <file>
    COPY <file> CLIPBOARD
    PROBE CLIPBOARD LINES

    CLIPBOARD LOOP
    CLIPBOARD LOOP END
    SET CLIPBOARD LOOP LINES
    SET CLIPBOARD DELAY

Type:
    Support and I/O Commands
Purpose:
    Read variables, strings, and commands from the system clipboard or write parameters, strings, or variables to the system clipboard.
Description:
    It is sometimes convenient to read data (or commands) from the system clipboard. Dataplot has implemented a number of commands to access data from the clipboard. Note that this capability is operating system and compiler dependent. These commands are currently supported for the Windows operating system for Dataplot executables built with the Intel Fortran compiler. Support for the X11 clipboard under Linux operating systems is anticipated for subsequent releases.

    Potential uses for the clipboard include:

    1. Dataplot does not read data from spreadsheets (e.g., Excel) directly. Copying data from the spreadsheet to the system clipboard and then reading the clipboard from Dataplot can provide a relatively easy way to extract data from the spreadsheet.

    2. The clipboard can provide a method for passing data between Dataplot and an external application.

    SYSTEM CLIPBOARD

    Operating systems typically use the clipboard to implement cut and paste operations. These can sometimes be used with Dataplot.

    For example, to read data from the clipboard you can do something like the following

      READ Y X1 X2
      <perform system paste operation>
      END OF DATA

    Note that this works for Linux systems where Dataplot is built with the gfortran compiler. However, it does not work with the Windows version of Dataplot built with the current version of the Intel Fortran compiler (it did work with some earlier versions of the Intel compiler).

    Likewise, if you have Dataplot commands stored in the clipboard, then you can paste into the current Dataplot terminal window. Again this works under Linux systems. However it does not work under Windows with the Intel compiler.

    DATAPLOT CLIPBOARD COMMANDS

    Although system cut and paste operations can be adequate for many purposes, it can also be useful to have programatic access to the clipboard. For example, the system cut and paste does not work correctly for the Windows version of Dataplot. In addition, programatic access can be useful for communicating with non-Dataplot applications.

    The commands above can be divided into several categories:

    1. The READ CLIPBOARD, READ STRING CLIPBOARD, and SET CLIPBOARD SKIP are used to read data or strings from the clipboard.

      The WRITE CLIPBOARD command can be used to write strings, parameters, or variables to the the clipboard.

    2. The CLIPBOARD RUN command is used to run the contents of the clipboard as a Dataplot macro. If the command CLIPBOARD PAUSE is encountered while executing the CLIPBOARD RUN command, then Dataplot will revert to reading commands from the terminal until a CLIPBOARD RESUME command is entered. At that point, Dataplot will revert back to reading commands from the clipboard. The SET CLIPBOARD RUN CLEAR <ON/OFF> command specifies whether the clipboard is cleared (ON) or not cleared (OFF) after a CLIPBOARD RUN command (the default is OFF).

    3. The CLIPBOARD CLEAR is used to clear the current contents of the clipboard. The LIST CLIPBOARD command is used to list the current contents of the clipboard. The CLIPBOARD COPY command is used to copy the contents of the clipboard to a user-specified file or to copy the contents of a user-specified file to the clipboard. The PROBE CLIPBOARD LINES returns the number of lines currently in the clipboard.

    4. The CLIPBOARD LOOP command is used to interogate the clipboard. That is, the clipboard will be continuously checked until it is not empty. If the clipboard is not empty, then the contents of the clipboard are executed as a Dataplot macro (when the end of the clipboard is reached, the clipboard is cleared). The CLIPBOARD LOOP END command is used terminate the CLIPBOARD LOOP command.

      The CLIPBOARD LOOP capability is primarily intended to allow an external application to interactively send commands to a Dataplot session. This is a feature that most Dataplot user's will typically not use directly.

Syntax 1:
    READ CLIPBOARD <x1> <x2> ... <xk> This syntax is used to read numeric variables from the clipboard.

    Note that the clipboard should contain only numeric variables. If a non-numeric character is encountered, an error will be generated and the READ will not be performed.

    This capability is useful for accessing parts of a spreadsheet. For example, many spreadsheets will contain summary tables and graphs. Writing these types of spreadsheets to ASCII files tends to result in files that need substantial clean-up before they can be read by Dataplot. Alternatively, you can copy the relevant data from the spreadsheet to the clipboard and then use the READ CLIPBOARD command to read that data into Dataplot.

    Generally, this command works best when rectangular areas (i.e., the variables do not contain missing cells). Missing cells denoted by commas will be read correctly. However, spreadsheets will typically separate values with tabs rather than commas when copying to the clipboard. In this case, missing data will not be handled correctly. If you have spreadsheet columns of unequal length, you may need to copy and read the columns individually.

    The ROW LIMITS and SET READ FORMAT commands are not used when reading variables from the clipboard. By default the SKIP command is ignored. If you would like the SKIP command to be honored, enter the command

      SET CLIPBOARD SKIP ON

    To revert to ignoring the SKIP command, enter the command

      SET CLIPBOARD SKIP OFF
Syntax 2:
    READ STRING CLIPBOARD <str1> <str2> ... <strk>
    where <str1>, <str2>, ... <strk> is a list of strings to be read.

    This syntax is used to read strings into Dataplot from the clipboard.

    String one is read from the first line of the clipboard, string two is read from the second line of the clipboard, and so on.

    Individual strings are limited to a maximum of 255 characters.

    By default the SKIP command is ignored. If you would like the SKIP command to be honored, enter the command

      SET CLIPBOARD SKIP ON

    To revert to ignoring the SKIP command, enter the command

      SET CLIPBOARD SKIP OFF
Syntax 3:
    WRITE CLIPBOARD <st1> <st2> ... <stk>
    where <st1>, <st2>, ... <stk> is a list of one or more strings and parameters to be written.

    This syntax is used to write strings and/or parameters to the clipboard.

    Dataplot will first print all specified strings. It will then print all specified parameters. Each string or parameter will be printed on a separate line. Parameters are printed using an E15.7 format.

    The total number of characters written to the clipboard is currently limited to 4096 characters. Dataplot will automatically add CR/LF to the end of each line written to the clipboard and an ending null byte. These Dataplot inserted characters count against the total character count.

    Note that this command will erase the current contents of the clipboard before writing the new strings and parameters.

    Writing strings and parameters cannot be mixed with writing variables to the clipboard. If the list of names includes both strings/parameters and variables, the variables will overwrite the strings and parameters.

Syntax 4:
    WRITE CLIPBOARD <st1> <st2> ... <stk>
    where <st1>, <st2>, ... <stk> is a list of one or more variables.

    This syntax is used to write variables to the clipboard.

    Numeric values are written using an E15.7 format. The SET WRITE FORMAT and SET WRITE DECIMALS commands are ignored when writing to the clipboard.

    The total number of characters written to the clipboard is currently limited to 5000000 characters. Dataplot will automatically add CR/LF to the end of each line written to the clipboard and an ending null byte. These Dataplot inserted characters count against the total character count.

    Note that this command will erase the current contents of the clipboard before writing the new strings and parameters.

    Writing strings and parameters cannot be mixed with writing variables to the clipboard. If the list of names includes both strings/parameters and variables, the variables will overwrite the strings and parameters.

    Matrices are not currently written to the clipboard.

Syntax 5:
    CLIPBOARD CLEAR

    If this command is entered, the current contents of the clipboard will be deleted.

Syntax 6:
    LIST CLIPBOARD

    If this command is entered, the current contents of the clipboard will be listed to the screen. A maximum of 240 characters for a given line will be printed.

    The SET HELP LINES command can be used to specify how many lines are printed at once. Enter HELP HELP LINES for details. The default is 20 lines.

Syntax 7:
    COPY CLIPBOARD <file> where <file> specifies the name of the file where the clipboard contents will be copied.

    If this command is entered, the current contents of the clipboard will be copied to the the specified file. Individual lines will be truncated at 255 characters.

Syntax 8:
    COPY <file> CLIPBOARD
    where <file> specifies the name of the file which will be copied to the clipboard.

    If this command is entered, the contents of the specified file will be copied to the clipboard. Individual lines will be truncated at 255 characters.

Syntax 9:
    PROBE CLIPBOARD LINES

    This command will return the number of lines in the clipboard. The result will be saved in the parameter PROBEVAL.

Syntax 9:
    CLIPBOARD RUN

    If this command is entered, Dataplot will execute each line in the clipboard as a Dataplot command.

    If this command is called from within a Dataplot macro (i.e., from a CALL <file> command), it will only be honored if the macro is a first level macro. That is, if you have nested CALL commands, CLIPBOARD RUN must be in the first macro called.

Syntax 10:
    CLIPBOARD PAUSE

    If Dataplot is executing commands from the clipboard, this command is used to revert reading commands from the terminal (or from a macro).

Syntax 11:
    CLIPBOARD RESUME

    If a CLIPBOARD PAUSE command was entered from the clipboard to revert to reading commands from the terminal, then this command can be used to resume executing the commands in the clipboard.

Syntax 12:
    CLIPBOARD LOOP

    If the CLIPBOARD LOOP command is entered, then the following algorithm is used:

    1. If the clipboard is currently active, then retrieve commands from the clipboard.

    2. If the clipboard is not currently active, then pause and check if anything is in the clipboard. The length of the pause is controlled by the SET CLIPBOARD DELAY command.

    3. If the clipboard is empty, restart the process. If the clipboard is not empty, then begin processing the contents of the clipboard as Dataplot commands.
Syntax 13:
    CLIPBOARD LOOP END

    This command is used to exit the CLIPBOARD LOOP command.

Syntax 14:
    SET CLIPBOARD LOOP LINES <value>
    where <value> is a parameter or number.

    This command specifies the maximum number of iterations for the CLIPBOARD LOOP. That is, it specifies the maximum number of times the clipboard will be interogated. If this maximum is reached, the CLIPBOARD LOOP command will be ended (it can be explicitly ended with the CLIPBOARD LOOP END command).

Syntax 15:
    SET CLIPBOARD DELAY &;lt;value>
    where <value> is a number or parameter that specifies the delay.

    If a CLIPBOARD LOOP command was previously entered, this command specifies the length of the delay when interogating the clipboard. That is, if the clipboard is empty, wait the specified length of time before checking the clipboard again. The delay is specified in seconds.

Syntax 16:
    SET CLIPBOARD RUN CLEAR <ON/OFF>
    where ON specifies that the clipboard will be cleared after a CLIPBOARD RUN command and OFF specifies that the clipboard will not be cleared after a CLIPBOARD RUN command.

    The default is OFF.

Examples:
    READ CLIPBOARD PRES TEMP TIME
    READ STRING CLIPBOARD STCLIP1
Note:
    These commands have been implented for the Windows version of Dataplot built using the Intel compiler.

    Extending this support to Unix/Linux and Mac OS X implementations is currently being investigated.

    2020/06: Support has been extended to Unix/Linux platforms via the xclip program. The xclip program is an X11 based command line program for accessing either the clipboard, the primary selection or the secondary selection. To specify which of these is accessed when a CLIPBOARD command is entered, use the command

      SET X11 SELECTION <CLIPBOARD/PRIMARY/SECONDARY>

    The default is CLIPBOARD and for Dataplot purposes this is what will typically be used.

    The CLIPBOARD commands work differently under Linux than under Windows. Under Windows, Dataplot uses library routines to access the clipboard directly. Under Linux, the xclip command is used to access the contents of the clipboard. Specifically (in the following, the "-selection clipboard" is replaced with "-selection primary" or "-selection secondary" depending on the value for the SET X11 SELECTION command)

      LIST CLIPBOARD - the following command is issued

        xclip -o -selection clipboard

      COPY CLIPBOARD <file> - the following command is issued

        xclip -o -selection clipboard > <file>

      COPY <file> CLIPBOARD - the following command is issued

        xclip -i -selection clipboard < <file>

      CLEAR CLIPBOARD - the following command is issued

        echo -n | xclip -selection clipboard

      READ CLIPBOARD - the xclip command is used to copy the contents of the clipboard to the temporary file "dpst5f.dat". Then the READ command reads the file "dpst5f.dat".
      WRITE CLIPBOARD - the WRITE command writes to the temporary file "dpst5f.dat". Then the xclip command is used to copy the contents of "dpst5f.dat" to the clipboard.
      CALL CLIPBOARD - the xclip command is used to copy the contents of the clipboard to the temporary file "zzzz_clipboard.dp". Then a "call zzzz_clipboard.dp" command is issued.

    The commands CLIPBOARD LOOP, CLIPBOARD PAUSE, CLIPBOARD RESUME and SET CLIPBOARD SKIP are not currently supported for Linux.

    The xclip command is not typically installed by default. However, package files are available for most common Linux installations. For example

      sudo dnf --install xclip - systems that use the Red Hat package manager (Fedora)

      sudo apt install xclip - systems that use the apt package manager (Ubuntu)

      sudo pacman -S xclip - - systems that use the pacman package manager (arch, Manjaro)

    If xclip is not available with your package manager, it can be built from source. The xclip program is lightweight, so the source build should be quick if you have the gcc compiler installed.

Note:
    Dataplot only supports text for clipboard operations. If the clipboard contains binary data (e.g., image data), then the results for reading the clipboard may be unpredictable.

    Extending Dataplot support for the clipboard to include binary data is not anticipated.

Default:
    None
Synonyms:
    CLIPBOARD is a synonym for CLIPBOARD CLIPBOARD RUN
    RUN CLIPBOARD is a synonym for CLIPBOARD RUN
    CLEAR CLIPBOARD is a synonym for CLIPBOARD CLEAR
    CLIPBOARD END LOOP is a synonym for CLIPBOARD LOOP END
    CLIPBOARD END OF LOOP is a synonym for CLIPBOARD LOOP END
    CALL CLIPBOARD is a synonym for CLIPBOARD RUN
    CB is a synonym for CLIPBOARD RUN
Related Commands:
    CALL = Execute Dataplot commands stored in an ASCII file.
    READ = Read data from an ASCII file.
Applications:
    Data I/O, Program Execution
Implementation Date:
    2014/12: Original implementation for Windows with Intel compiler.
    2019/03: Added SET CLIPBOARD RUN CLEAR
    2019/03: Added CALL CLIPBOARD and CB as synonyms for CLIPBOARD RUN
    2020/06: Added clipboard support for Linux via the xclip program
Program:
     
    COPY BERGER1.DAT CLIPBOARD
    SET CLIPBOARD SKIP ON
    SKIP 25
    READ CLIPBOARD  Y X BAT
    CLIPBOARD CLEAR
        

Privacy Policy/Security Notice
Disclaimer | FOIA

NIST is an agency of the U.S. Commerce Department.

Date created: 12/17/2014
Last updated: 07/01/2020

Please email comments on this WWW page to alan.heckert@nist.gov.