473,401 Members | 2,125 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,401 software developers and data experts.

my code just stops

I have a script and I ran it and it just seems to stop. The reason I
say so is that the script does not get to the second alert. OK here it
is:

function show(input) {
if (input.length == 1) {
for (i=0;i<input[0].length;i++) {
document.write(input[0][i]);
}
document.write("<br>");
} else {
for (i=0;i<input.length;i++) {
for (j=0;j<input[0].length;j++) {
document.write(input[i][j]);
}
document.write("<br>");
}
}
}
function squareroot(input) {
output = copy2darr(input);
alert(output.join("\n"));
top = new Array(output[0].length);
alert(output.join("\n")); // This is the alert it never gets to
for (var i=0;i<output[0].length;i++) {
top[i] = "—";
}
alert(top);
n = output.unshift(top);
alert(output.join("\n"));
for (var i=0;i<output.length;i++) {
if (i == 0) {
n = output[i].unshift("┌");
} else {
n = output[i].unshift("│");
}
}
for (var i=0;i<output.length;i++) {
if (i != output.length-1) {
n = output[i].unshift(" ");
} else {
n = output[i].unshift("\\");
}
}
return output;
}
document.write("long hyphen: —<br>leftmost peice:
┌<br>rightmost peice: ┐<br>taller bar: │<br>square
root symbol: √<br><br>");
arr = [
[" ","5"," "," "," "," "],
["x"," "," ","+"," ","x"]];
show(arr);
show(squareroot(arr));

Jul 23 '05 #1
2 1008
"greenflame" <al*********@yahoo.com> writes:
I have a script and I ran it and it just seems to stop. The reason I
say so is that the script does not get to the second alert. OK here it
is: function squareroot(input) {
output = copy2darr(input);
alert(output.join("\n"));
top = new Array(output[0].length);
Here you are assigning to the global variable "top". It already exists
(window.top) and is a reference to the outermost frame in a set of
frames, or just the page itself if no frames are involved. In, at least,
IE, the global variable "top" is not writable, and you get an error trying.

Generally, you should make all your variables local:
var top = new Array(output[0].length);
i.e., declare the variable with "var <variablename>".
alert(output.join("\n")); // This is the alert it never gets to

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #2
ok This seemed to work. Thanks

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

53
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is...
109
by: Andrew Thompson | last post by:
It seems most people get there JS off web sites, which is entirely logical. But it is also a great pity since most of that code is of such poor quality. I was looking through the JS FAQ for any...
4
by: D Witherspoon | last post by:
Sometimes if I build the app I will get intellisense, undo, and code completion (automatic completion of if stataments etc), but after a few lines of code this stops. I lose any code completion...
16
by: graham.reeds | last post by:
I am updating a website that uses a countdown script embedded on the page. When the page is served the var's are set to how long the countdown has left in minutes and seconds, but the rest of the...
0
by: Traci | last post by:
I have a summary form that has two columns of unbound textboxes for actual cost and marked up price. There are eight textboxes in each column. There are also two unbound subforms. Each set of...
9
by: BoloBaby | last post by:
I have an extremely vexing problem occurring in a program that I am writing. Consider the following block of code: Dim pDancer As New BEDancer mintIndex = mintIndex + 1 pDancer.DancerName =...
5
by: Adrian Enders | last post by:
I have something that I have never seen before in a MS development product. I have a pretty simple call to a network directory that looks something like this ... Dim dirFolder As...
2
by: iwdu15 | last post by:
hi, i have the following line of code Dim fsUser As New IO.FileStream(SnPath & s.Identity & "\UserData\info.ppf", IO.FileMode.Create, IO.FileAccess.Write) in a sub, SnPath is not null,...
5
by: Raj | last post by:
Following is a code to replace blanks in entered string with adequate number of tabs & spacings as required. I've taken the width of tab as 5 characters here. The problem that occurs here is for...
11
by: raamay | last post by:
when i download movies my download stops in the middle. I use Free Download Manager and i get the message "File not found in the server" error. The download manger tries to reconnect to server...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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.