passing parameters to a panel

Started by Thomas Bock, January 17, 2020, 10:15:03 AM

Previous topic - Next topic

Thomas Bock

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

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

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

Mike,

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