Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Windows clipboard questions

16 views
Skip to first unread message

Grod

unread,
Oct 4, 2003, 8:16:16 AM10/4/03
to
1. Is is possible to use gawk to read the Windows clipboard, make a
transformation of the text there and then replace the clipboard text
with the transformed text?

2. Is it possible to create a small single file executable from a gawk
program that will do #1?

Patrick TJ McPhee

unread,
Oct 5, 2003, 3:45:07 PM10/5/03
to
In article <ffd662ea.03100...@posting.google.com>,
Grod <ggroth...@volcanomail.com> wrote:

% 1. Is is possible to use gawk to read the Windows clipboard, make a
% transformation of the text there and then replace the clipboard text
% with the transformed text?

Not as such. It's possible to write an extension function to retrieve
and replace the clipboard text, but you'd have to do that part in
C or some other compiled language. Also, support for extension functions
might not be compiled in to any binary distributions, so you might have
to compile gawk from sources to get it.

% 2. Is it possible to create a small single file executable from a gawk
% program that will do #1?

No. Or at least, not without changing the gawk source code and recompiling
it.

You can do this with Rexx, using the Regina interpreter, Rexx/Wrapper, and
my w32funcs package. You'll still need a C compiler, although Rexx/Wrapper
will generate the C code. Also, your executable will need to be distributed
with a couple of .dlls.

--

Patrick TJ McPhee
East York Canada
pt...@interlog.com

Patrick TJ McPhee

unread,
Oct 5, 2003, 3:57:14 PM10/5/03
to
In article <blpsc3$3sq$1...@news.eusc.inter.net>,
Patrick TJ McPhee <pt...@interlog.com> wrote:

% In article <ffd662ea.03100...@posting.google.com>,
% Grod <ggroth...@volcanomail.com> wrote:
%
% % 1. Is is possible to use gawk to read the Windows clipboard, make a
% % transformation of the text there and then replace the clipboard text
% % with the transformed text?
%
% Not as such.

Sorry, I got so caught up going on about difficult ways of dealing with the
issue, I forgot the easy way. unxutils (http://unxutils.sf.net) has a
program which writes the text content of the clipboard to stdout, and
another which writes its stdin to the clipboard, so you can

BEGIN { incmd = "gclip"; outcmd = "pclip"
while (incmd | getline) {
var = do_something($0, var)
}
close(incmd)
print var | outcmd
close(outcmd)
}

(note that this is not tested).

Kenny McCormack

unread,
Oct 5, 2003, 4:37:02 PM10/5/03
to
In article <blpsc3$3sq$1...@news.eusc.inter.net>,
Patrick TJ McPhee <pt...@interlog.com> wrote:
...

>You can do this with Rexx, using the Regina interpreter, Rexx/Wrapper,
>and my w32funcs package. You'll still need a C compiler, although
>Rexx/Wrapper will generate the C code. Also, your executable will need
>to be distributed with a couple of .dlls.

Only mildly off-topic (since this thread specifically mentions GAWK), you
can also do it with TAWK - and it does (*) go all into one big executable,
with no DLLs (and no tricky "extracting out the DLLs to the current
directory" at runtime tricks)

(*) Read "does" as "can". It is also possible to go the small executable
route.

Stepan Kasal

unread,
Oct 6, 2003, 3:23:41 AM10/6/03
to
Hello,

On Sun, 05 Oct 2003 20:37:02 GMT, Kenny McCormack wrote:
> Only mildly off-topic (since this thread specifically mentions GAWK), you
> can also do it with TAWK - and it does (*) go all into one big executable,
> with no DLLs (and no tricky "extracting out the DLLs to the current
> directory" at runtime tricks)
>
> (*) Read "does" as "can". It is also possible to go the small executable
> route.

I beleive this was not off-topic at all. Really the TAWK language doesn't
differ from standard awk so much. And if the program calls the utils from
unxutils itself, we get a solution consisting only of three executables.

It this is what is needed, it should be worth buying TAWK.

Stepan

0 new messages