Hi,
Every time I try to access the contents of the following array it returns that it is undefined. I have tried multiple variations on accessing the arrays syntax wise but get different errors every time.
When I try to do it the way listed below I get the undefined error I talked about before.
Code: - var array = new Array();
-
var i, j, txt;
-
var str = new Array();
-
-
try{
-
array = document.tsv.read_in("u:\\test.txt");
-
for(i=0;i<array.length;i++)
-
str[i]=array[i];
-
for(i=0; i<array.length; i++)
-
array[i] = new Array();
-
}
-
catch(err)
-
{
-
txt="There was an error on this page.\n\n";
-
txt+="Error description: " + err.description + "\n\n";
-
txt+=err.stacktrace + "\n\n";
-
txt+=err.stack + "\n\n";
-
txt+="Click OK to continue.\n\n";
-
alert(txt);
-
}
-
-
for(i=0; i<array.length; i++)
-
{
-
var str2 = str[i];
-
var temp = str2.split("\t");
-
for(j=0;j<temp.length;j++)
-
{
-
array[i][j] = temp[j];
-
}
-
document.write(array[0][0]);
-
}
-
-
for (i=1;i<array.length; i++)
-
{
-
document.write("<div class=\"silverheader\" id=\""+i+"\"><a href="+i+">"+array[i][0]+"</a></div>");
-
document.write("<div class=\"submenu\">");
-
for(j=0;j<temp.length;j++)
-
document.write(array[i][j]+"\t");
-
document.write("</div>");
-
}
I realize the code above is ridiculously inefficient but I'm just trying to figure out what I'm doing wrong. Any suggestions?
16 1916 Dormilich 8,658
Recognized Expert Moderator Expert
line #6, you’re overwriting your array variable.
@Dormilich
That's my initializing line, the array has nothing in its contents before that point.
Dormilich 8,658
Recognized Expert Moderator Expert
that doesn’t matter. whatever it has been before, after line #6 it’s something different.
Yea, that's what I was going for cause that's when the contents of the array are first filled. I should have probably said this in the first post but during my debugging attempts I accessed the contents of the array after line 6, and I got the correct output - that is the contents that I brought in with the read_in function. When I try and access the contents in line 30 I get undefined for all index values. So I doubt that line 6 is where my problem is.
Dormilich 8,658
Recognized Expert Moderator Expert
do you have a test page, where I can look for myself?
gits 5,390
Recognized Expert Moderator Expert
simplyfied it a bit to test in firebug-console -> basically it seems to work: - var my_array = [];
-
var str = [];
-
var i, j, txt;
-
-
-
my_array = ['foo\t8\tbar', 'foo','foo','foo','foo','foo'];
-
-
for (i = 0; i < my_array.length; i++) {
-
str[i] = my_array[i];
-
my_array[i] = [];
-
}
-
-
for(i = 0; i < my_array.length; i++) {
-
var str2 = str[i];
-
var temp = str2.split("\t");
-
-
for(j = 0; j < temp.length; j++) {
-
console.log(temp[j]);
-
-
my_array[i][j] = temp[j];
-
-
console.log(my_array[i][j]);
-
}
-
}
-
-
console.log(my_array);
-
how does the array initially look like?
gits,
I have attached the result of the code that you pasted above which still gives me the same "undefined" response when I try to access the 2-d array. Initially, the array consists of a line from a tsv file that is parsed in using the java read_in function that I created.
If I try to access the array using the syntax "array[i,j]" I get the problem where each interation of the outer for loop overwrites the same row of the 2-d array. Basically at the end I have a 2-d array that has the same info throughout. Anybody have any answers to why I'm having these problems?
gits 5,390
Recognized Expert Moderator Expert
what the code ... in fact yours ... produce is the following for my_array: - [["foo", "8", "bar"], ["foo"], ["foo"], ["foo"], ["foo"], ["foo"]]
is that what you expect?
since you use temp which has the las split operation's result assigned at this time there might be undefined values since temp might have had different lengths ...
Yea that's the output I expect but unfortunately don't get. The temp arrays all have the same length as I'm inputting from a tsv file that has the same number of columns for the entire document.
Could it be a problem with the way my compiler or javascript settings on my browser? Cause if it works for you guys then there shouldn't be a reason why it doesn't work for me.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Christopher Johannsen |
last post by:
Good Day:
I am working on building a tool Using ASP/COM & IIS5.1 for a
non-administrative technical support team to change domain passwords for
users. I have the basic interface built and working from my developement
machine (Windows XP Pro SP 1A) which is hosting the pages for now. The
problem is that when I try to access the site from a browser on a different
pc using my credentials (IIS is running in Windows Authentication), it...
|
by: KKramsch |
last post by:
My code is generating this type of error:
Security Error: Content at http://nonexistent.org/somepage.html
may not load data from about:blank.
The "about:blank" page mentioned in the error message is a pop-up
window, whose content is 100% dynamically-generated, and which is
in fact *owes its existence* to code in the referring page
(nonexistent.org/somepage.html), along the lines of something like
|
by: leslie_tighe |
last post by:
Hello,
I have a method on a com+ object that is returning an array of objects.
I know the array is popluated as calls to check the ubound and lbound
show valid values. However, any calls to get the value of a cell in the
array results in a type mismatch error.
|
by: mad |
last post by:
I am new here and don't know if someone has encountered and discussed
this problem before. I appreciate any help to this problem.
I am building a new Oracle database (8.1.7) and Win 2000/IIS 5 for
development. After I moved ASP pages over from another server (also
Oracle 8.1.7 and Win 2000/IIS 5), the error occurred when recordset's
MoveNext is called. Here is the code:
<% Set cmdTemp = Server.CreateObject("ADODB.Command")
Set rsProd...
|
by: arunkv |
last post by:
Hi Guys ...
This problem has been bugging me for over 5 days now.
I am trying to access a web service running in a Tomcat Server (a
Linux box) via a C#.Net page and I get the following error:
"The underlying connection was closed: An unexpected
error occurred on a receive."
The flow is as follows.
| |
by: ken.beutler |
last post by:
I am getting a 404 error when trying to access an ASP page from a
remote machine (via Internet Explorer). However, the asp page is
processed successfully when accessing this page from the local machine.
I checked permissions from IIS administration and from explorer and
nothing seemed out of the ordinary. Other ASP pages work from other
virtual directories, but for some reason this one does not.
Any suggestions out there? Thank you...
|
by: gakhanna |
last post by:
Hi,
I am getting the following error when I tried connecting to Task Center.
In task center I have scheduled daily incremental backup which also didnt ran.
Here comes the Error which I am getting:
DBA1177N A database connection to the Tools Catalog Database
"TOOLSDB" cannot be made. SQLCODE "-22205"
Explanation:
|
by: RogerInHawaii |
last post by:
I would like to pass an array by reference to a function so that I can modify the contents of the array and effectively "return" that array to the caller.
I tried doing this:
function MyFunction(&$MyArray)
{
MyArray = "First";
MyArray = "Second";
}
|
by: Nathan Sokalski |
last post by:
When I attempt to access a Microsoft Access database from my website, I
recieve the following error:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Security Exception
Description: The application attempted to perform an operation not allowed
by the security policy. To grant this application the required permission
please contact your system administrator or change the...
|
by: sayid |
last post by:
Hello,
I have a problem when altering a DIV-element from another frame.
The frameset looks like this:
<frameset rows=0,0,* border=0>
<frame name=header src=/header.htm scrolling=no noresize="true" frameborder=0>
<frame name=border src=/border.htm scrolling=no noresize="true" frameborder=0>
<frameset cols=200,* border=0>
<frameset rows=*,0 border=0>
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |