Welcome!

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

SignUp Now!

Sharing CLIP1 to CLIP9 with another TCC

Aug
1,904
68
Starting a new tcc.exe, and then executing the CLIP command, shows that CLIP1 to CLIP9 are empty.

In an already running instance of tcc.exe, CLIP1 to CLIP9 have text in each clipboard.

Is there a method to share CLIP1 to CLIP9 amongst tcc.exe instances?

That is, CLIP1 to CLIP9 appear to be local to tcc.exe, not global.

Can CLIP1 to CLIP9 be made to act Global, just like Aliases, Functions, History, and Directory history?

1673016150668.png

Joe
_x64: 1
_admin: 1
_elevated: 1

TCC 29.00.17 x64 Windows 10 [Version 10.0.19044.2364]
 
If you really need this sort of thing, with a global alias list (and function list) list you can store named/numbered strings (perhaps modest ones) that will be available to all instances of TCC. For example, with these

Code:
alias setclip `alias clip_%1 %2$`

function getclip `%@alias[clip_%1]`

you can

Code:
setclip 1 foo

setclip 2 Now is the time^r^nfor all good men ...

Then, in any TCC sharing the global lists,

Code:
v:\> echo %@getclip[1]
foo

v:\> echo %@getclip[2]
Now is the time
for all good men ...

I have wondered what I could do in a plugin. Making shared memory of a fixed size (like the global lists) is easy enough. Making it variable in size would be (I reckon), as Rex said, clunky and of dubious utility.
 
Thanks @vefatica,

I've added these to my alias.lst and function.lst

They work as advertised.

I'll do some tests,
and see what happens.

I was also thinking about a plugin,
but could not find anything in the SDK about clipboards 1 to 9.

I was thinking of using SMOPEN, but as you and @rconn pointed out, it would require memory of a fixed size;
Code:
::
:: Get a handle to Global memory
::
set hnd=%@smopen[10000,"Global\Clip9"]
echo Handle of Global\Clip9 is: %hnd
::
:: Create a string to store in Global memory
::
set theString=This is Spinal Tap
echo theString is: %theString
::
:: Set the pointer to zero
::
set ptr=0
::
:: Write some ASCII text to shared memory
::
echo %@smwrite[%hnd,%ptr,a,%theString] > nul
::
:: Read some ASCII text from shared memory
::
echo Reading Shared Memory via TCC:
echo %@smread[%hnd,%ptr,a,%@len[%theString]]
::
:: Close the handle to Global memory
::
echo %@smclose[%hnd] > nul

Joe
 
Thanks for the reminder about @SMOPEN. I had vaguely remembered that TCC had some mechanism for implementing shared memory but I couldn't think of it.

I don't think a fixed size is much of a handicap. I'm monkeying with a plugin that uses a shared data segment of 1,000,000 characters. That could be treated (as the user sees fit) as a 2-dimensional array of any appropriate dimensions (e.g., 1000 1000-byte strings, 10000 100-byte strings, et c.). It's hard to imagine needing more that for just text. And that's only 2,000,000 bytes which is peanuts by modern standards and compared to TCC's typical working set.
 
Back
Top