The better way to pass containers between objects/forms using the Args() class, and not by converting to a string
If you need to pass a container between objects/forms using the Args class, don't convert it to a string and then back, use parmObject() and ContainerClass()! I see many suggestions about converting it to a string, which can have much more unpredictable results and is not as versatile.
You wrap your container in the class ContainerClass() and then unwrap it at the other end.
Make your call like this:
To test this, create a form (Form1) and overwrite the init method and put in this code:
Then create a Job and put in this code:
And then run the job!
You wrap your container in the class ContainerClass() and then unwrap it at the other end.
Make your call like this:
And retrieve it like this:args.parmObject(new ContainerClass(["Real container", 1234, "Not con2str container"]));
containerClass = element.args().parmObject() as ContainerClass;
myContainer = containerClass.value();
To test this, create a form (Form1) and overwrite the init method and put in this code:
public void init() { ContainerClass containerClass; container conValue; if (!(element.args() && element.args().parmObject() && element.args().parmObject() is ContainerClass)) throw error("@SYS22539"); super(); containerClass = element.args().parmObject() as ContainerClass; conValue = containerClass.value(); info(strFmt("The container contains '%1'", con2Str(conValue))); }
Then create a Job and put in this code:
static void JobForm1(Args _args) { Args args; FormRun formRun; args = new Args(); args.name(formStr(Form1)); args.parmObject(new ContainerClass(['Real containers', 1234, 'Not con2str containers'])); formRun = classFactory.formRunClass(args); formRun.init(); formRun.run(); formRun.wait(); }
And then run the job!
Comments
Post a Comment