Monday, November 9, 2015

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:
args.parmObject(new ContainerClass(["Real container", 1234, "Not con2str container"]));
And retrieve it like this:
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");
    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.parmObject(new ContainerClass(['Real containers', 1234, 'Not con2str containers']));
    formRun = classFactory.formRunClass(args);

And then run the job!


  1. This article is very valuable AND informative. It contains complete description about how to form containers. Thank you for demonstration. It was very helpful.

  2. There is a wide scope of food containers and beverages bottles available and maybe even in your pantries.plastic containers

  3. You made such an interesting piece to read, giving every subject enlightenment for us to gain knowledge. Thanks for sharing the such information with us to read this... office cabin

  4. A round of applause for your mind blowing article. Much thanks to you. Fantastic.