Forum Discussion

william_roe's avatar
william_roe
Super Contributor
9 years ago
Solved

Pushing Items onto Array

How do you push items onto an array? The following throws an exception.   function ReadAllCribs() { var AllCribs = {}; Project.Variables.Cribs.Reset(); for (; !Project.Variables.Cr...
  • chrisb's avatar
    9 years ago

    Your all cribs array object should be created with square brackets, using braces creates an object not an array object. I'm going to take a guess here and assume you were trying to append the value with a string "CribNumber" before adding it to array.

     

     

    function readAllCribs() {
    
    
        var allCribs = [];
        
        Project.Variables.Cribs.Reset();
        while (!Project.Variables.Cribs.IsEOF() {
            allCribs.push("CribNumber" + Project.Variables.Cribs.Value); 
            Project.Variables.Cribs.Next();
        }
    
    
    
    
    }

     

     

     

    }