# ESTK error "Can not assign value"

Advocate ,
Apr 07, 2016 Apr 07, 2016

Copy link to clipboard

Copied

Dear friends, a new project has started - and of course new problems arise:.

The function SumOf (list of values) works perfectly,

but an equivalent function VsumOf (list of variables) stops at line 16 in the first iteration of the loop: Can not assign value.

At this point the variable result is just -132.09 - way out of some sort of numeric problem.

```var z = SumOf (11.1, -11.9, 12345679.0, -12345679.0, 124.5, -17, 18.9, 2.2, 2.5, 2.5, 2.5, 31.31, 312345679, -312345679); alert ("SumOf the numbers = " + z); // giving 166.610000014305  (figures after the 000 are artifacts)

var z = VsumOf (11.1, -11.9, 12345679.0, -12345679.0, 124.5, -17, 18.9, 2.2, 2.5, 2.5, 2.5, 31.31, 312345679, -312345679); alert ("VsumOf the numbers = " + z);

function VsumOf (valuePairs) {  var nArguments = arguments.length;  var j, z, result = 0;  if (Math.floor(nArguments/2) * 2 !== nArguments) {return undefined;}    for (j = 0; j < nArguments; j=++2) {    if (isNaN(arguments)) {return NaN;}        // should be skipped in calling environment    if (isNaN(arguments[j+1])) {return NaN;}    z = arguments * arguments[j+1];    result = result + z;                          // <<== Can not assign value ???  }  return result;}

// this one works correctlyfunction SumOf (values) {  var nArguments = arguments.length;  var j, result= 0;  for (j = 0; j < nArguments; j++) {    if (isNaN(arguments)) {return NaN;}        // should be skipped in calling environment    result = result + arguments;  }  return result;}
```

Any ideas what this error message really means?

TOPICS
Scripting

Views

424

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

## 1 Correct Answer

Enthusiast , Apr 07, 2016 Apr 07, 2016
Hi Klaus,just change your line 12 to
for (j = 0; j < nArguments; j=j+2) {
That should work.

Likes

2 Replies 2
Enthusiast ,
Apr 07, 2016 Apr 07, 2016

Copy link to clipboard

Copied

Hi Klaus,

just change your line 12 to

 for (j = 0; j < nArguments; j=j+2) {

That should work.

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Advocate ,
Apr 08, 2016 Apr 08, 2016

Copy link to clipboard

Copied

LATEST

Au weia,

such simple syntactic error not spotted - shame on me!

Klaus

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Resources
Fixed Issues
Download Adobe FrameMaker