Midrange News for the IBM i Community


Posted by: Tim Brinker
Writing to Windows Clipboard
has no ratings.
Published: 25 Oct 2012
Revised: 23 Jan 2013 - 1553 days ago
Last viewed on: 24 Apr 2017 (3884 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

Writing to Windows Clipboard Published by: Tim Brinker on 25 Oct 2012 view comments(12)

Is it possibly to write to the windows clipboard from either an RPGLE program or from a 5250 session?  For example I have an item entry screen, I want to capture the item number, then a pipe and then item description to the clipboard.  Once in the clipboard the information will be pasted to another application.

 

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS

(Sign in to Post a Comment)
Posted by: TFisher
Premium member *
Comment on: Writing to Windows Clipboard
Posted: 4 years 6 months 13 hours 31 minutes ago
Edited: Thu, 25 Oct, 2012 at 13:21:57 (1643 days ago)

I don't think you would want to use the clipboard for that.  Obviously you can do a copy and paste between a Windows app and your 5250 Client Access session.  That would probably be better than trying to copy into your clipboard and then running some process that will have to try to access and convert the data into something you can use.

 

What software are you using to enter the item number?  And is it web-based? 

Posted by: DaleB
Premium member *
Reading, PA
Comment on: Writing to Windows Clipboard
Posted: 4 years 6 months 13 hours 25 minutes ago

Nothing comes to mind, at least not directly. There may be other ways to accomplish the goal, though.

Can't speak for other vendors, but if you're using IBM PC5250, you could use STRPCCMD to start a Windows command.

Another possibility is the 'Incoming Remote Command' feature of System i Access, which is an rexec daemon. From server you use RUNRMTCMD. But this method requires you to know the host name or IP address of the Windows PC (which isn't super difficult to get, just another thing to consider.)

Either way you'd have to write the Windows program that you're going to put in the command string, which would accept the text as a parameter, and the only thing it would do is put it on the clipboard and quit.

Posted by: tbrinkereaglewindowcom
Premium member *
Comment on: Writing to Windows Clipboard
Posted: 4 years 6 months 11 hours 33 minutes ago

Dale - Thanks for the reply.  Interesting idea.

 

TFisher - I am interfacing to an existing program that accepts input from the clip board.  The item number would be entered in green screen :(.

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Writing to Windows Clipboard
Posted: 4 years 6 months 11 hours 7 minutes ago
Edited: Thu, 25 Oct, 2012 at 14:40:41 (1643 days ago)

I doubt it is possible. iSeries Access is setup to use Data Queues for Host-to-PC communications. But it is an interesting challenge, in deed.

You could setup a data queue that is used to add stuff the the Windows Clipboard.

Post stuff to that data queue from your RPG program.

Then on the windows-side, write a program that waits on the data queue for data, when it gets something it copies that dataqueue data to the clipboard.

The host side is easy, just data queue APIs on the PC-side you'd need to write a program.

 

Posted by: TFisher
Premium member *
Comment on: Writing to Windows Clipboard
Posted: 4 years 6 months 10 hours 53 minutes ago
Edited: Thu, 25 Oct, 2012 at 14:47:14 (1643 days ago)

Sorry, I totally misread what you are trying to do.  I was thinking you wanted to "read" from the clipboard into an RPG program. It should be a bit easier to do what you want to do. 

 

I assume that the PC app doesn't allow the item number to be passed in as a parm?

 

You can use the STRPCCMD or RUNRMTCMD technique and then use something like 'echo your item number here | clip' to pipe the text into the clipboard.  You may have to create a BAT file on the PC and run that, but I think you can just use echo.  I have not done anything like this in a while.

 

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Writing to Windows Clipboard
Posted: 4 years 6 months 9 hours 51 minutes ago
Edited: Thu, 25 Oct, 2012 at 15:49:25 (1643 days ago)

Amazing what you learn on this site. Good tip, Fish!

STRPCCMD PCCMD('ECHO 5381 | clip') PAUSE(*NO)

Copies the value '5381' to the clipboard in Windows.

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Writing to Windows Clipboard
Posted: 4 years 6 months 9 hours 28 minutes ago

Fish,

Is RUNRMTCMD possible if your PC is remote? I connect from home to System i, how do I direct RUNRMTCMD to my PC session?

Posted by: TFisher
Premium member *
Comment on: Writing to Windows Clipboard
Posted: 4 years 6 months 9 hours 27 minutes ago

thanks Bob!  Every once in a while I come up with something halfway useful.

Posted by: tbrinkereaglewindowcom
Premium member *
Comment on: Writing to Windows Clipboard
Posted: 4 years 6 months 9 hours 16 minutes ago

TFisher / Bob - That is awesome! 

Posted by: Ringer
Premium member *
Comment on: Writing to Windows Clipboard
Posted: 4 years 6 months 5 hours 40 minutes ago

Pipe it to a CLIP huh? Never heard of CLIP before. Well done Fish.

CLIP

De!--script--ion:
    Redirects output of command line tools to the Windows clipboard.
    This text output can then be pasted into other programs.

Parameter List:
    /?                  Displays this help message.

Examples:
    DIR | CLIP          Places a copy of the current directory
                             listing into the Windows clipboard.

    CLIP < README.TXT   Places a copy of the text from readme.txt
                                    on to the Windows clipboard.

Chris Ringer

Posted by: DaleB
Premium member *
Reading, PA
Comment on: Writing to Windows Clipboard
Posted: 4 years 5 months 29 days 17 hours 3 minutes ago

Never heard of clip before either; cool.

Did a little testing. Original question needed to embed a pipe as part of the clipboard data, which seems to be problematic. If you include it in quotes, the quotes are also put on the clipboard. Can you use a different separator? If not, you may have to parse out the quotes.

Also, when I paste, I'm always getting a CRLF. Not sure if this is coming from echo or from clip, but either way you may need to be aware of that.

Posted by: clbirk
Premium member *
Comment on: Writing to Windows Clipboard
Posted: 4 years 5 months 27 days 14 hours 22 minutes ago

another thought is that you might look at aaron bartell's mowyourlawn.com, his rpg2dt function, which you utilize the data queue (which I know was already suggested) and then you call whatever from the other side (which obviously would utilize the "clip" command).

One reason I suggest this is not everyone is utilizing i series access and other telnet products do not necessarily support strpccmd, etc.

 

I use rpg2dt, to open browser windows (like say you want to track a ups package, on the green screen, they click a function key) and a browser window opens up with the ups tracking information. Or say that you want to force a bat to run or a program to execute, or you want to prefill a web page, etc. lots of different ideas.