PxPlus User Forum

Twitter Twitter Twitter

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

Thomas Bock

  • Diamond Member
  • *****
  • Posts: 129
    • 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

  • Gold Member
  • ****
  • Posts: 56
  • Once PxPlus guru, reskilled in C#, Java, PHP, JS
    • 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 | Company

Mike King

  • Administrator
  • Diamond Member
  • *****
  • Posts: 3405
  • Mike King
    • View Profile
    • PVX Plus Technologies
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.


Thomas Bock

  • Diamond Member
  • *****
  • Posts: 129
    • 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.