Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Comments re Clipboards

Jun
562
4
1. The help file entry for the TYPE command should be updated to mention that it works not only with CLIP: but with the numbered clipboards as well.

2. The help should somewhere note that redirection is not protected with the clipboards. One can enter a command such as

echo New clipboard text > clipn:

and the text will replace what was already in clipn:, even if that clipboard had not been empty and redirection protection was configured to be on.

3. Perhaps it is obvious, but it might be worth noting also that text can be appended to a clipboard using

echo More clipboard text >> clipn:

4. The help notes that the @LINES function can be used with the clipboards. However, it appears to me that the two variables that are supposed to be returned by the function (namely %_lines_maxlen and %_lines_maxloc) do not work. Indeed, the values remain what they were the last time that @LINES was used with an actual file. That's too bad, because I had already thought of a use for them with the clipboards. Rex, is that a bug that can be fixed?

5. I just noticed a slight mistake/confusion in the help for the @CLIPWN function. The syntax and the example have a space after the comma. If there is such a space, it becomes part of the clipboard contents as a leading space. The syntax should be

@CLIPWN[clipboard,string]

The example is technically OK but will put " save this line" (without quotes) into the clipboard. The help says that the function returns 0 if the write was successful. Just curious: How could it not be successful? Anything wrong I tried produced a syntax error message and did not run the command line. Of course, the function has to return something, and it is good to be told what it is.

I'm coming to appreciate that these extra clipboards can be very useful. They have a lot of the convenience of temporary files without the need to avoid name conflicts and the risk of leaving clutter behind. And they don't have to be pre-dimensioned like arrays.
 
I'm trying to figure out what is meant in the help by the following:

When an app saves something to the default clipboard (CLIP: or CLIP0:), TCC will rotate the existing clipboard entries before saving the new CLIP0. CLIP0: will become CLIP1:, CLIP1: becomes CLIP2:, etc. The old CLIP9: will be lost. If you save something to CLIP1: - CLIP9:, none of the other clipboard entries will be modified.

I suddenly had the worry that if I stored some information in one of the extra clipboards, it might get rotated to another location before I used it. I hope that the last sentence above is saying that the normal stack-like operation of the clipboard set does not occur if something has been explicitly written to that clipboard.

I did an experiment of running a bat file that sequentially wrote to clipboards 1 through 9 with a delay.

do i = 1 to 9
*clip /s clip%i: This is clipboard %i
*clip clip%i:
delay /b 2
enddo

While that batch file was running, I manually copied text in another window to the clipboard. That text seemed to go only into clipboard 0. On the other hand, sometimes text that I clip manually does not go into clip: at all. I have not been able to figure out when it is saved and when it isn't.

Well, the experiment was a serious failure. I wrote text into clip2: and then started clipping text manually from my text editor. Unfortunately, the clipboards did their stack push, and the contents of clip2: ended up in clip4:.

C:\commands\bat>clip /s clip2: Text stored in clipboard 2 & clip
CLIP0:
CLIP1:
CLIP2: Text stored in clipboard 2
CLIP3:
CLIP4:
CLIP5:
CLIP6:
CLIP7:
CLIP8:
CLIP9:

C:\commands\bat>clip
CLIP0: do i = 1 to 9
CLIP1: enddo
CLIP2: setlocal
CLIP3:
CLIP4: Text stored in clipboard 2
CLIP5:
CLIP6:
CLIP7:
CLIP8:
CLIP9:

Perhaps the clipboard content is protected only while a batch file is running. Unfortunately, no. I started with a clean set of clipboards and then saved two items, leaving the following (text in the first two clipboards, the rest empty):

C:\commands\bat>clip
CLIP0: enddo
CLIP1: setlocal
CLIP2:

Then after running the batch file and copying some more text to the clipboard manually, I ended up with the following:

C:\commands\bat>clip
CLIP0: @echo off
CLIP1: *clip clip%i:
CLIP2: enddo
CLIP3: This is clipboard 1
CLIP4: This is clipboard 2
CLIP5: This is clipboard 4
CLIP6: This is clipboard 5
CLIP7: This is clipboard 7
CLIP8: This is clipboard 8
CLIP9: This is clipboard 9

This would not be good if my batch program had been trying to use data stored in specific clipboards, since some moved to different clipboards and some disappeared.

If I clear all the clipboards and then run the batch file without doing any manual clipboard copying, I end up with what I expect:

CLIP0:
CLIP1: This is clipboard 1
CLIP2: This is clipboard 2
CLIP3: This is clipboard 3
CLIP4: This is clipboard 4
CLIP5: This is clipboard 5
CLIP6: This is clipboard 6
CLIP7: This is clipboard 7
CLIP8: This is clipboard 8
CLIP9: This is clipboard 9

I'm really confused. For the clipboards to be used in the way I have been envisioning, we need a way to stop the rotation.
 
More and more confusion. Now I wanted to experiment with writing to CLIP: multiple times to watch the stack progression. What I find is that sometimes data goes into the clipboard and sometimes not. When it goes in, the stack advances.

First, here is the batch file.

:: Configure delay
set delay=2

:: Clear all clipboards
clip /z

:: Put some initial data in clip1: and show clipboard content
clip /s clip1: Initialize clip1:
clip clip0: clip1: clip2: clip3:
delay %delay

:: Now write data to clip: several times and watch data rotate

do i = 1 to 5
echo.
echo Running i = %i
echos Line %i > clip:
delay %delay
clip clip0: clip1: clip2: clip3:
delay %delay
enddo

quit

Here is the result of one run. (I don't get the same results each time.) The data for i = 3 and 4 did not get stored.

C:\commands\bat>test2
CLIP0:
CLIP1: Initialize clip1:
CLIP2:
CLIP3:

Running i = 1
CLIP0: Line 1
CLIP1: Initialize clip1:
CLIP2:
CLIP3:

Running i = 2
CLIP0: Line 2
CLIP1: Line 1
CLIP2: Initialize clip1:
CLIP3:

Running i = 3
CLIP0: Line 2
CLIP1: Line 1
CLIP2: Initialize clip1:
CLIP3:

Running i = 4
CLIP0: Line 2
CLIP1: Line 1
CLIP2: Initialize clip1:
CLIP3:

Running i = 5
CLIP0: Line 5
CLIP1: Line 2
CLIP2: Line 1
CLIP3: Initialize clip1:

I have the program CLIPX, which saves multiple Windows clipboard entries, and all five lines do show up there. They just don't make it into the TCC clipboard. Just to be sure, I closed CLIPX. It made no difference.

I just ran the script again, and only "Line 4" got stored.

Running i = 5
CLIP0: Line 4
CLIP1: Initialize clip1:
CLIP2:
CLIP3:

Is this something peculiar to my configuration?
 
Back
Top