Creating & Using Multiple Clipboards


Staff member
May 16, 2008
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:

type foo.txt > clip:

You can access the lines in the clipboard in a FOR loop like this:

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


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.

alias clp:=c:\temp
function clp=`%@line[clp:%1,%2]`

I can now name my clipboards clp:1, clp:2, clp:3, etc.

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.

Similar threads