473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

javascript 'function not defined' error in recursion

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 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW XYZ";

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>");
}
Jun 21 '06 #1
1 17536
AnnaV
3
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.
Jun 22 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

19
by: Fabian | last post by:
Well, what can I say...I really hate Javascript. I am not programming as profession but I sometimes work with PHP with MySQL, ASP with Ms Access/SQL Server. I have done something in VB and when...
6
by: den 2005 | last post by:
Hi everybody, Question 1: How do you set the values from server-side to a client-side control or how do you execute a javascript function without a button click event? Question 2: How do you...
1
pbmods
by: pbmods | last post by:
VARIABLE SCOPE IN JAVASCRIPT LEVEL: BEGINNER/INTERMEDIATE (INTERMEDIATE STUFF IN ) PREREQS: VARIABLES First off, what the heck is 'scope' (the kind that doesn't help kill the germs that cause...
2
by: lielar | last post by:
Hi I'm writing a javascript class object that creates objects of itself. Take for example function One(x){ this.x = x; } One.prototype.addOne = function(x) {
30
by: Jeff Bigham | last post by:
So, it appears that Javascript has a recursion limit of about 1000 levels on FF, maybe less/more on other browsers. Should such deep recursion then generally be avoided in Javascript?...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.