Vector append() and assign() question

I was creating a dropdown in the config and saw lately Vector append() & assign() support JS arrays directly ( :+1:). The help states

In JScript you can pass a standard array to this method to copy the array into a Vector.

but both throw an exception for me:

    var v = DOpus.create.vector();
    var a = [ 'Foo', 'Bar' ];          v.append(a); // exception
    var b = new Array( 'Foo', 'Bar' ); v.append(b); // exception
    v.append([ 'Foo', 'Bar' ]);                     // exception
    v.append(new Array( 'Foo', 'Bar' ));            // exception
    v = DOpus.create.vector([ 'Foo', 'Bar' ]);      // no exception
    DOpus.output('cnt: ' + v.count); // ...but returns 0
    v.push_back('Foo');
    DOpus.output('cnt: ' + v.count); // works perfectly fine

Am I missing something very obvious or misinterpreting the docs?

Sorry about that, and thanks for reporting it!

It has been fixed for the next beta.

1 Like

New beta is out with this change: Directory Opus 12.24.2 (Beta)

1 Like

Thanks Leo, you guys rock!

Both methods work as expected now:

    var _v1 = DOpus.create().vector();
    _v1.assign(['Foo', 'Bar', 'Baz']);
    _v1.insert(0, 2); // default for dropdown
    var _v2 = DOpus.create().vector();
    _v2.push_back(2); // default for dropdown
    _v2.append(['Foo', 'Bar', 'Baz']);
1 Like