PxPlus User Forum

Main Board => Discussions => Wish List => Topic started by: Thomas Bock on January 17, 2020, 10:15:03 AM

Title: passing parameters to a panel
Post by: Thomas Bock on January 17, 2020, 10:15:03 AM
For a dynamic panel invocation it would be very useful to pass the parameters in form of a data structure.

--- suggestion #1 ---
params$["ARG_1"] = "A"
params$["ARG_2"] = "B"
params$["ARG_3"] = "C"
process panel$, lib$, params$[all]

--- suggestion #2 ---
params$ += "ARG_1=A" + sep
params$ += "ARG_2=B" + sep
params$ += "ARG_3=C" + sep
process panel$, lib$, params$
Title: Re: passing parameters to a panel
Post by: Stéphane Devouard on January 17, 2020, 10:25:17 AM
Thomas,

You could convert your associative array to a JSON string before the PROCESS, and then convert back ARG_1$ from JSON to assoc. array in the panel pre-display routine

Regards
Title: Re: passing parameters to a panel
Post by: Mike King on January 17, 2020, 11:06:49 AM
Rather than JSON why not just use an IOLIST?

Something like this:

   Client_ID$="123456"
   Account$="ABC123"
   Company$="MyCo"
!
   MyIolist$=CPL("IOLIST Client_ID$, Account$, Company$")
   Args$=REC(MyIolist$)
   PROCESS "Panel","Library",Args$, MyIolist$
! ...


Then in the Pre_Create logic for the panel:

   READ DATA FROM Arg_1$ TO IOL=ARG_2$

Now if you want to pass the data back add the following to the wrapup of the panel:

   ARG_1$=REC(ARG_2$)

And after the PROCESS statement in the caller:

   READ DATA FROM ARGS$ TO IOL=MyIolist$

This will allow you to pass not only ARG_nn$ values but actual variables by name.

Title: Re: passing parameters to a panel
Post by: Thomas Bock on January 20, 2020, 02:50:16 AM
Mike,

Sometimes my tunnel vision hides the most obvious solution.
Thank you for bringing this to my attention.