cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

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

dgopois
13-Aquamarine

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

Hi,

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

David

ACCEPTED SOLUTION

Accepted Solutions
dgopois
13-Aquamarine
(To: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.

View solution in original post

1 REPLY 1
dgopois
13-Aquamarine
(To: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.

Announcements

Top Tags