Skip to main content
13-Aquamarine
April 4, 2014
Solved

How to pass an ACL array in a javascript function and how to read the array in the javascript function ?

  • April 4, 2014
  • 1 reply
  • 1122 views

Hi,

How to pass an ACL array in a javascript function and how to read the array in the javascript function ?

David

    Best answer by dgopois

    I have found the solution in Arbortext Documentation(Arbortext Programmer’s Reference):

    Similarly, there are two ways to retrieve an ACL array from JavaScript. The first method uses the ACL join function to concatenate the ACL array into a string that initializes a JavaScript array. For example, you can use the following ACL code to pass the ACL array created above to JavaScript:

    javascript("var jsArr = [" . join(aclArr) . "]");

    This method is not limited by the ACL string token limit.

    You can also use a loop to retrieve the array, element by element, as shown in the following JavaScript example:

    var count = parseInt(Acl.eval("count(aclArr)"));

    var lowBound = parseInt(Acl.eval("low_bound(aclArr)"));

    var jsArr = new Array(count);

    for (var i = 0; i < count; i++) {

    var ai = lowBound + i;

    jsArr[i] = Acl.eval("aclArr[" + ai + "]");

    }

    This method translates the arbitrary array index bounds in an ACL array to the zero-based array index in JavaScript. It also uses the parseInt method to convert the Java string returned by Acl.eval into a JavaScript number.

    1 reply

    dgopois13-AquamarineAuthorAnswer
    13-Aquamarine
    April 4, 2014

    I have found the solution in Arbortext Documentation(Arbortext Programmer’s Reference):

    Similarly, there are two ways to retrieve an ACL array from JavaScript. The first method uses the ACL join function to concatenate the ACL array into a string that initializes a JavaScript array. For example, you can use the following ACL code to pass the ACL array created above to JavaScript:

    javascript("var jsArr = [" . join(aclArr) . "]");

    This method is not limited by the ACL string token limit.

    You can also use a loop to retrieve the array, element by element, as shown in the following JavaScript example:

    var count = parseInt(Acl.eval("count(aclArr)"));

    var lowBound = parseInt(Acl.eval("low_bound(aclArr)"));

    var jsArr = new Array(count);

    for (var i = 0; i < count; i++) {

    var ai = lowBound + i;

    jsArr[i] = Acl.eval("aclArr[" + ai + "]");

    }

    This method translates the arbitrary array index bounds in an ACL array to the zero-based array index in JavaScript. It also uses the parseInt method to convert the Java string returned by Acl.eval into a JavaScript number.