On this Page

    _merge (Call DocOrigin Merge)

    Runs Merge, passing the argument list as command line parameters.

    Syntax

    _merge(args)

    Parameters

    args is either a string listing all the Merge command-line parameters or a JavaScript object whose properties define the command-line parameters. If args is a string, the string will be passed as-is to the Merge program. If args is a JavaScript object, each object property name is converted to a DocOrigin-style -name parameter and the property's value becomes the parameter's value. The property names mirror the command line option names.

    Returned Value

    The return value from Merge. Merge will return zero (0) if it runs successfully. If the program cannot be found or cannot be run the return code is platform-specific. On Windows _merge returns a value of -801 to indicate that the Merge program could not be found or executed. For Linux and other Unix platforms, it returns -1. As of 3.0.002.02, the return code when Merge is not found is 111.

    Description

    Your application will wait until Merge has completed before resuming. As a convenience, the -logfile specification that was provided to the app that is running your script will automatically be passed along to the Merge app instance that you are launching. Of course, if you specify the -logfile option explicitly, your option will be the one in effect.

    Example

     var arglist = "-form=$F/myform.xatw -data=$D/mydata.xml";
     var rc = _merge(arglist);
     if (rc != 0) _printf("The Merge return code was: %d\n", rc);
     var args = new Object();
     args.form = $F + "/myform.xatw";	// or "$F/myform.xatw";
     args.data = $D + "/mydata.xml";		// or "$D/mydata.xml";
     var rc = _merge(args);
     if (rc != 0) _logPrintf("The Merge return code was: %d\n", rc); 

    This presumes that you have set up definitions for where the $F and $D folders are in your installation's Paths.prm override file. See $X String Substitutions. In the first variation, if the form name had a space in its name, e.g. Sample_Invoice.xatw, then you would have to quote it as in:

    -form="$F/Sample_Invoice.xatw"

    It has to be double quotes, not single quotes, and hence the overall quoting around the whole arglist would use single quotes. Don't forget to put a slash (/) at the start of the base file name. In the second variation, it is safe to use $X path substitutions on all platforms. If you pass $X in the first variation it will be incorrectly interpreted as an environment variable by Linux systems. Do check your return codes.

    See Also

    _run (Execute Another Program)
    _runScript