views:

37

answers:

3

Hi,

I have a script and I'm almost done but I get this error and frankly I have no idea what is wrong here. I'm rather new to Javascript so I suspect I did something wrong in the syntax somewhere. Here is an extract from the script containing the offending line :

var gc = 0;
var seg;
var segCount = 0;
var groupCount = 0;
var groupLevel = 0;
var segments = new Array();
var sk = "";
for(gc = 0; gc <= groupLevel; gc++)
{
    if(gc >= groupDelimiters.length) break;
    if(seg.name() == groupDelimiters[gc])
    {
        //ok we start another group
        grKeys.startNewGroup(groupLevel, groupCriterionExtractors[groupLevel](segCount), groupCount);
        groupLevel = gc + 1;  //This line is flagged with the error in the title
        groupCount++;
    }
}

ideas, pointers, any help would be appreciated.

edit - I got screwed by the $%*& markup syntax from outer space. Here is the code as it should have appeared.

A: 

there’s a { missing in your code and the for() syntax is wrong.

for ([initialExpression]; [condition]; [incrementExpression])

ah, yes, your for() loop won’t execute anything as it is now.

Dormilich
yes of course.. I posted too fast and got screwed by the markup, it mangled part of the code. Your answer gave me the heads-up on that... thanks :-)
Newtopian
A: 

This:

for(gc = 0; gc = groupDelimiters.length) break;
    if (seg.name() == groupDelimiters[gc])
    ...

Should probably be

for (gc = 0; gc < groupDelimiters.length; gc++) {
    if (seg.name() == groupDelimiters[gc])
    ...
glebm
yes you are correct, it was actually, just that the markup syntax and regex that govern them mangled my code somehow... darn thing... I do not know why but this markdown syntax really gives me trouble. I mean I tried many of them and never had so much difficulty with it... anyhow.. thanks for taking some time to answer.
Newtopian
+2  A: 

It's hard to tell without more info but I would guess from the error message that the following code:

groupCriterionExtractors[groupLevel]

is yielding the value 1.0 which you are then trying to call with:

(segCount)

So it's like saying:

grKeys.startNewGroup(groupLevel, 1.0(segCount), groupCount);

There are several problems with the above code such as the for loop, post what you're trying to do and some test data and I can help more

Peter McGrattan
Darn... exactly... I created an array of functions but my algorithm was not correct and overflowed the array into unknow space. Should have caught that one, but the compiler error sent me in the wrong direction.
Newtopian