1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Creating & Using Multiple Clipboards

Discussion in 'T&T - Scripting' started by nchernoff, Jun 5, 2008.

  1. nchernoff

    nchernoff Administrator
    Staff Member

    Joined:
    May 16, 2008
    Messages:
    42
    Likes Received:
    2
    Migrated From JP Software Wiki

    Windows Clipboard


    4NT has built-in support for the Windows clipboard. The CLIP: name and the @CLIP[] function are used to access the Windows clipboard. You can copy a block of text to the clipboard using this syntax:

    Code:
    type foo.txt > clip:
    You can access the lines in the clipboard in a FOR loop like this:

    Code:
    for %f in (@clip:) do echo %f
    or

    Code:
    echo %@clip[2]
    Private Clipboards

    The only problem with the Windows clipboard is that there is just one. Once you overwrite it with something new, you've lost whatever was there previously. Using directory aliases and a simple function definition you can easily support multiple private clipboards.

    Directory aliases were introduced with 4NT v8 (I think). They provide a shorthand way to reference a specific directory.

    Code:
    alias clp:=c:\temp
    function clp=`%@line[clp:%1,%2]`
    I can now name my clipboards clp:1, clp:2, clp:3, etc.

    Code:
    type foo.txt > clp:1
    
    for %f in (@clp:1) do echo %f
    
    echo %@clp[1,2]
    
    Note that these "clipboards" are private to 4NT and won't be usable by other Windows applications. They are just disk files however. In the case of clp:1, the file is named c:\temp\1. So, you could access the file from a windows app.
     

Share This Page