javascript 'function not defined' error in recursion
Question posted by: Sylaris
(Newbie)
on
June 21st, 2006 10:10 AM
hi, i have a problem which recursion fits perfectly, however; after working with the base function (which has no errors and works correctly) the recursions return a "function not defined" error in ff's js console. i tried a few things that came to mind but nothing has changed it... i found some interesting articles on the net regarding javascript's callbacks, and found out that due to callbacks recursion may end up eating a lot more memory than normal recursion does, which makes it sound like js and recursion don't go together.
the second time i call value1(), when it is in the first loop of the recursive function, i get the 'function not defined' error. i also get a not defined error regarding the chars string on that same line if you get past the function error. i'm guessing its related...
any help is appreciated.
<script type="text/javascript">
var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWX YZ";
function value1(baseChar, base, options) {
this.baseChar = baseChar;
this.base = base;
if(options == "")
this.valid = new Array(0);
else {
this.valid = new Array(0);
for(var i=0; i<options.length; i++)
this.valid.push(options.substring(i,i+1));
}
this.child = new Array(0);
}
function mod() {
var aNum = 0;
var input = "\"eHgMYUn_MWW[SLZ!kKOiM\\SX[Uif'GcaO]YU`eWPJIv|g`YTVTlrUPQT`R_T MgIO~pcM[QHaQVrYI^u'f,ueHgMYU,";
var v1opt = new value1("", 0, chars);
recurse1(v1opt);
}
function recurse1(v1opt) {
document.write("base char: "+ v1opt.baseChar +"<br />");
document.write("base: "+ v1opt.base +"<br />");
document.write("valid: "+ v1opt.valid.join() +"<br />");
for(var i=0; i<v1opt.valid.length; i++) {
if((v1opt.base + v1opt.valid[i].charCodeAt(0)) <= 1286) {
document.write("child: "+ v1opt.valid[i].charAt(0) +"<br /><blockquote>");
var a = new value1("", 0, chars);
child = v1opt.child.push(a);
for(var j=0; j<chars.length; j++)
if((child.base + chars.charCodeAt(j)) <= 1286)
child.valid.push(chars.charAt(j));
}
}
if(v1opt.child.length != 0)
for(var i=0; i<v1opt.child.length; i++)
recurse1(v1opt.child(i));
document.write("</blockquote>");
}
|
|
June 22nd, 2006 01:45 PM
# 2
|
Re: javascript 'function not defined' error in recursion
May be th problem is in v1opt.child(i), as if the recursion is working correctly with scalar types. Have U tried to call the recurse1 for any scalar type?
You can assign this object to any variable and try to call for this one.
Not the answer you were looking for? Post your question . . .
189,324 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).
|
|
|
Latest Articles: Read & Comment
Top Javascript / DHTML / Ajax Forum Contributors
|