Page 1 of 1
Onclick response
Posted: Tue Feb 27, 2018 11:53 am
by machine0318
I have an output field that when clicked, I want the application to think I pressed the F8 button. I have defined the onclick of the output field to pui.click("btnCF08"); and btnCF08 has a response defined of iQtys of type indicator. Ultimately, I need the click to call another RPG program that has a parameter defined. How do I get my program to recognize that iQtys should be on or directly call the RPG program onclick?
Re: Onclick response
Posted: Tue Feb 27, 2018 1:25 pm
by Kaylee Law
Thank you for writing in!
If your end goal is to call another RPG program, you can use the pui.run() API in the onclick event of your output field to call RPG programs. For example:
Code: Select all
pui.run({program:"LIBRARY/PROGRAM"});
You can find more information on the pui.run() api here:
http://www.profoundlogic.com/docs/pages ... Id=7864464
~Kyle
Re: Onclick response
Posted: Tue Feb 27, 2018 1:52 pm
by machine0318
How do I specify a parameter with pui.run? I can't find an example and I'm not familiar with js.
Re: Onclick response
Posted: Tue Feb 27, 2018 4:12 pm
by Kaylee Law
machine0318 wrote:How do I specify a parameter with pui.run? I can't find an example and I'm not familiar with js.
To pass parameters with pui.run() you need to add a configuration option to add a javascript object that contains the parameters. For example:
Code: Select all
pui.run({
program:"LIBRARY/PROGRAM",
params:{
p1:"parm1",
l1: 50,
p2:"parm2",
l2: 50,
p3:"parm3",
l3: 50
}
});
defines an object that contains 3 parameters of length 50.
But after re-reading your original post, I am not sure this will be the solution you are looking for. When using pui.run() in Rich Display Applications, instead of control returning to the calling program after the called program ends, the session will end.
You mention that you have a button with id of "btnCF08" with a response bound to the feild iQtys which is defined as an indicator. In your RPG you can just use iQtys, like you would any other indicator, for example:
RPG CODE
if iQtys = *on;
//call program
endif;
Alternatively, we also have an API that simulates a button press.
You can find more information on the pressKey() API here:
http://www.profoundlogic.com/docs/pages ... Id=4849987
~Kyle
Re: Onclick response
Posted: Thu Mar 08, 2018 10:30 am
by Scott Klement
pui.run() is used to start a new Rich Display session that runs an anonymous program.
If you are simply trying to call another RPG program in the same session, you can do so the same way you did it in green-screen applications. Just use the standard RPG prototype with the EXTPGM keyword, or the old-fashioned CALL/PARM opcodes. There's no special logic needed for a Rich Display, just use a standard call like you've always done.