XML Feeds

.

[javascript-dev] js question from a newbie

Greg peripatitis at gmail.com
Wed Mar 26 19:29:07 MDT 2008


Hi i started this week to program a little bit with javascript .
For starters i made a simple henon map ,which works ok , but now i'd like to be able to store these into two dimentional arrays and see if i can find the numbers that repeat to use them to trigger perhaps different sets of initial conditions .

So i started reading about arrays in javascript and in my first example (filling an array and printing it reversed) there is a 'undefined ' message poping up in max window.
Could anybody please let me know whats going on ?

here is the simplistic code :

// printing and filling an  array 


editfontsize = 16 ;

// my inlets and outlets 

inlets = 1 ;
outlets = 1;

// number of elements
 var x ;
var myarray = new Array () ;


function msg_float(r) 
{  
 
  if (inlet == 0)
    { x = r ;
      fillarray(x) ;
      myreverse();
     
      
      
                         }
}

function fillarray(k)
{
var i ; 
 
for (i = k ; i > 0 ; i--)
       { myarray[i] =  i ;
        post ();
        post(myarray[i]) ;  }

        post();
        post ("my array has a lenght of" , myarray.length) ;
        post();
        
}
// trying to print a reversed array 
   function myreverse() 
 { 
var  z = myarray.reverse() ;
  post (z) ;
                 }


More information about the javascript-dev mailing list