PxPlus User Forum

Twitter Twitter Twitter

Author Topic: passing parameters to a panel  (Read 1610 times)

Thomas Bock

  • Diamond Member
  • *****
  • Posts: 177
    • View Profile
passing parameters to a panel
« 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$

Stéphane Devouard

  • Diamond Member
  • *****
  • Posts: 122
  • PxPlus guru with skills in PHP, JS, C#, Java
    • View Profile
    • Stéphane's Web Resume
Re: passing parameters to a panel
« Reply #1 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
Stéphane Devouard
Portfolio | Work

Mike King

  • Diamond Member
  • *****
  • Posts: 3810
  • Mike King
    • View Profile
    • BBSysco Consulting
Re: passing parameters to a panel
« Reply #2 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.

Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

Thomas Bock

  • Diamond Member
  • *****
  • Posts: 177
    • View Profile
Re: passing parameters to a panel
« Reply #3 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.