The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Help me find bug
denmarks
post Jul 21 2013, 02:34 PM
Post #1


Advanced Member
****

Group: Members
Posts: 207
Joined: 17-January 08
Member No.: 4,734



I am working on a program a step at a time. A rarely do HTML and Javascript from scratch so I am always forgetting details.
So far this page should convert to binary. When the page appears just enter 6 numbers less than 64. Click enter and an alert should display the binary. I am getting an error that it can't find the function. I am sure it is something simple but Firefox is no help.

I get 2 errors
nimRoutine not found and ; missing.

I sure it is something simple but I can't find the error.

http://www.dmmarks.com/nim.html


This post has been edited by denmarks: Jul 21 2013, 02:41 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jul 21 2013, 03:44 PM
Post #2


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



Two things jump out. It's 'if', not 'If', lower case. You shouldn't use semicolon at the end of function braces. That's just at the end of statements.

With those changes, at least it does something and the errors go away. Alas it returns 0 for everything. But a step in the right direction anyway. wink.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
denmarks
post Jul 21 2013, 04:02 PM
Post #3


Advanced Member
****

Group: Members
Posts: 207
Joined: 17-January 08
Member No.: 4,734



I found the problem. The VAR on the subtables.

This post has been edited by denmarks: Jul 21 2013, 04:23 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jul 21 2013, 04:26 PM
Post #4


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



That's not the only change you made.

Before
CODE
nimTable = new Array(5);
nimTable[0] = new Array(5);
nimTable[1] = new Array(5);
nimTable[2] = new Array(5);
nimTable[3] = new Array(5);
nimTable[4] = new Array(5);
nimTable[5] = new Array(5);


Now
CODE
var nimTable = new Array(5);
var nimTable[0] = new Array(5);
var nimTable[1] = new Array(5);
var nimTable[2] = new Array(5);
var nimTable[3] = new Array(5);
var nimTable[4] = new Array(5);
var nimTable[5] = new Array(5);


Using var when you declare the array is fine, but not when you set the individual values.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jul 21 2013, 04:26 PM
Post #5


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



QUOTE(denmarks @ Jul 21 2013, 11:02 PM) *

I found the problem. The VAR on the subtables.


Now you tell me! tongue.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
denmarks
post Jul 21 2013, 04:28 PM
Post #6


Advanced Member
****

Group: Members
Posts: 207
Joined: 17-January 08
Member No.: 4,734



Sorry. I'm still trying to get back into the swing of things. Now the problems are just logic.

This post has been edited by denmarks: Jul 21 2013, 04:29 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jul 21 2013, 04:49 PM
Post #7


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



Just joking. Happens all the time. wink.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
denmarks
post Jul 21 2013, 05:41 PM
Post #8


Advanced Member
****

Group: Members
Posts: 207
Joined: 17-January 08
Member No.: 4,734



QUOTE(pandy @ Jul 21 2013, 02:49 PM) *

Just joking. Happens all the time. wink.gif


Thanks for your help. I am sure I will be back. I got the convert to binary working fine. That is all for today. I assume you know about the game of Nim. The algorithm is pretty simple. Converting it to code it what is tricky. I first programmed it for the IBM 1620 about 50 years ago. I thought I would create a Javascript. I did not like what was available.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jul 21 2013, 06:05 PM
Post #9


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



No, I didn't. But I've read a little about it now.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 25th April 2024 - 08:30 AM