Javascript functions accessed via the JS API may return different responses with z-Way 1.x and 2.x. While the z-Way 1.x JS API recognizes correctly that a function result is an array, the z-Way 2.x JS API has sometimes some troubles, as the following examples are showing. Custom functions accessed via the JS API are used in the following sections.
Let's start with the example that that has different results for the two major z-Way versions:
Code: Select all
Get_TestArray1 = function() {
var ThreeVal = [65,66,67];
return ThreeVal;
}
* z-Way 2.x: ABC <- This seems be an bug in the JS API!
* z-Way 1.x: [65,66,67]
z-Way 2.x seems to consider the values as ASCII characters that concatenated together to a string (ASCII(65)='A').
From the moment that a single array element cannot be considered anymore as ASCII characters (e.g. element is an integer between 0 and 255) a proper array is returned. For example, all elements are strings:
Code: Select all
Get_TestArray2 = function() {
var ThreeVal = ["65","66","67"];
return ThreeVal;
}
* z-Way 2.x: ["65","66","67"]
* z-Way 1.x: ["65","66","67"]
Z-Way 2.x returns also an array if one of the element is a double:
Code: Select all
Get_TestArray3 = function() {
var ThreeVal = [65.1,66,67];
return ThreeVal;
}
* z-Way 2.x: [65.1,66,67]
* z-Way 1.x: [65.1,66,67]
The following example show that also a value above 255 "forces" the JS API to return an array:
Code: Select all
Get_TestArray4 = function() {
var ThreeVal = [265,66,67];
return ThreeVal;
}
* z-Way 2.x: [265,66,67]
* z-Way 1.x: [265,66,67]
And here is a final array example that uses as final array element an empty string:
Code: Select all
Get_TestArray5 = function() {
var ThreeVal = new Array(65,66,67,"");
return ThreeVal;
}
* z-Way 2.x: [65,66,67,""]
* z-Way 1.x: [65,66,67,""]
Scalar results are not translated into an ASCII char, as the following example shows:
Code: Select all
Get_TestScalar = function() {
return 65;
}
* z-Way 2.x: 65
* z-Way 1.x: 65
The following z-Way version have been used for the above examples:
* 1.x: 1.4, 1.5, 1.7
* 2.x: 2.01-RC6
Let's hope that this obvious bug of the JS API is fixed soon!