Page 1 of 1

STRPCCMD

Posted: Mon Dec 03, 2012 12:15 pm
by kaw
How to open excel by clicking a button?

Thank you!

Re: STRPCCMD

Posted: Mon Dec 03, 2012 9:29 pm
by Scott Klement
If your spreadsheet is on IBM i, consider using the pui.download() JavaScript API from an onclick event in a button.

Here's the docs:
http://www.profoundlogic.com/docs/displ ... 8config%29

In Genie, you'd want to set your onclick to something like:

Code: Select all

pui.download({ "id":  "/ifs/path/to/spreadsheet.xls", "inline": true, "contentType": "application/vnd.ms-excel" });
You'd also need to set up your PUIDNLEXIT program to allow the download. (See link, above, for more info.)

It's also possible to do this with STRPCCMD... But, with STRPCCMD, the spreadsheet needs to be accessible to the PC already (i.e. available via Windows Networking or something)

Code: Select all

strpccmd pccmd('X:\Path\To\spreadsheet.xls')
But, again, that'll only work if the pathname is already something accessible to windows, whereas with pui.download() it's transferred over HTTP the same as the web page. I personally find that more elegant.

Re: STRPCCMD

Posted: Tue Dec 04, 2012 2:19 pm
by kaw
I'm Genie. I have an RPG program on green screen allows you to create files and places them in the IFS and opens automatically with to command STRPCCMD and I would do the same on Genie.
I tried a button
STRPCCMD pccmd ('L: \ www \ kaw \ toto.pdf')
but I have the following error message:OnClick Error: Unexepected identifier

Re: STRPCCMD

Posted: Tue Dec 04, 2012 3:40 pm
by Scott Klement
STRPCCMD would need to be called from a CL program, the QCMDEXC API, or another similar API. You can't run it directly from a Genie button, since that button actually runs on your PC's browser, it doesn't run on IBM i -- and therefore can't run IBM i commands.

However, there's a JavaScript API named runPCCommand that you can call from a Genie button. It does the same thing as STRPCCMD -- basically, just a JavaScript implementation of STRPCCMD.
http://www.profoundlogic.com/docs/displ ... ommand+%29

But, beware of backslashes. in the CL environment, backslash is just a normal character. But with JavaScript, it has a special meaning, so you need to be sure you escape it. This is described in the preceding link as well.