This is weird.
Forgetting previous stuff here is the problem I now am seeing/have.
This code:
counter = counter + 1;
context.set("COUNTER",counter);
node.warn("TOTAL is " + total);
total = total + x;
node.warn("TOTAL IS NOW " + total);
context.set("total",total);
msg.payload = total;
return msg;
This is what I see - given I reset the flow at the start.  (Sorry it scrolled off the top of the screen)
NR 2.0.1
It starts at 0 and each time I press the 8 it increments by 8.
On the OTHER  machine....
This is what I'm getting:
NR 1.2.6maths  isn't being honoured.
             
            
              
            
           
          
            
            
              You will find the context value total or the variable new_value is a string. Use parseInt to convert it to a number before adding the new number.
             
            
              
            
           
          
            
            
              But why is it working on the other machine?
Or (sorry) is that for 1.2.6 and was fixed in 2.0.1?
             
            
              
            
           
          
            
            
              Because on the other machine they will be numbers. When you add two numbers you get a number. When you add a string and a number it gets concatenated.
Just make sure they are both numbers by using parseInt.
             
            
              
            
           
          
            
              
                Colin  
              
                  
                    8 October 2021 09:19
                   
                  7 
               
             
            
              
Unless they are not integers, in which case use parseFloat.  In fact I would just use Number() which will convert it based on the contents.
             
            
              1 Like 
            
            
           
          
            
              
                system  
              
                  
                    22 October 2021 09:19
                   
                  8 
               
             
            
              This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.