hmmm…help! chasing errors. core js problem i.e. me not getting it

Mar 14, 2007 at 8:50pm

hmmm…help! chasing errors. core js problem i.e. me not getting it

hi,

i’m trying to get this script running. it works fine when i call the
functions independently, but the toggle function at the bottom which
is supposed to run the whole thing gives me
“net[nodeid] has no properties” errors while to me it is very well
defined, but well…
i’ve tried to isolate, but I don’t seem to find it. it’s probably a
scope thing, but i’m not that proficient enough yet in js to spot it
i’m afraid.
i hope this is not too long, and that it makes sense to you…

thanks in advance!

isjtar

oh yes, first run the resetNet, then toggle 1

////
initiate////////////////////////////////////////////////////////////////
////////////////////////
//globals
inlets = 1;
outlets = 2;
autowatch = 1;
post(“init”);

//initiate inductive scale
var induct = 1;

//netholder
netsize = 100;

var net = new Array(netsize);
for (var i = 0; i < netsize; i++){
net[i] = new node(i);
}

//
startnode///////////////////////////////////////////////////////////////
///////////////////////
function node(i){
//create array
this.connectArray = new Array(100);
//lower than 1 for scaling
this.depth = 1;
this.activationbw = 128;
}

////basic probing
functions///////////////////////////////////////////////////////////////
//////////
//get node
function getNode(nodeid){
outlet(1, net[nodeid].connectArray);
}

//get net
function getNet(){
for(var nodeid = 0; nodeid < netsize; nodeid++){
getNode(nodeid);
}
}

//reset node
function connectReset(nodeid) {
for (var i = 0; i<100; i++) {
net[nodeid].connectArray[i] = 60;
}
}

//reset net
function resetNet(){
for(var n_id = 0; n_id < netsize; n_id++){
connectReset(n_id);
}
}

////the
netfunctions////////////////////////////////////////////////////////////
////////////////////
//fquantile
function fquantile(nodeid) {
var rnd = Math.random();
var total = 0;
var sum = 0;
for (var index = 0; index < 100; index++) { //get total, index max =
array size
total += net[nodeid].connectArray[index];
}
for (var index2 = 0; index2 < 100; index2++) { //compare index sum
to total * rnd
sum += net[nodeid].connectArray[index2];
if (sum >= rnd * total) {
outlet(0,index2);
return index2; //output data
}
}
}

//activation and timing, see run
function net_timing(){
//sequence nodeids
var nodeid2 = fquantile(nodeid2);
outlet(0, nodeid2);
//activation ramps
for(var actramp = 0; actramp < netsize; actramp++){
for(var i2 = 0; i2 < netsize; i2++){
net[actramp].connectArray[i2] = Math.round(net[actramp].connectArray
[i2] * net[i2].depth);
post(arguments.callee.task.iterations);
}
}
//output
var output = getNet();
outlet(0, output);
}

////run the
net!////////////////////////////////////////////////////////////////////
/////////
function toggle(number) {
if(number == 1){
var randomstart = Math.round(Math.random() * netsize);
var nodeid = fquantile(randomstart);
run = new Task(net_timing, this);
run.interval = 50;
run.repeat(100);
}
else{
run.cancel;
}
}

#30824

You must be logged in to reply to this topic.