473,397 Members | 1,974 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.

Remote FileSystemObjects

I am a near total novice, trying to write some Javascript code that will
display certain elements in a comma separated value file (gifts.csv) in
tabular form when a page is loaded. I have come up with the following which
works fine when I view the page in my coding tool (AceHTML 5 Pro). Basically
it sets up an array, opens the csv file, reads each line from the file,
decides whether the line needs processing and if so loads each value into an
element of the array and writes some of them out. There are some table tags
thrown into appropriate places.

<script>

information = new Array(10);
y = new ActiveXObject("Scripting.FileSystemObject");
gift = y.opentextfile("gifts.csv",1);
x = document.write("<table>");

do {
x = document.write("<tr>");
giftinfo = gift.readline();

if (giftinfo.charAt(0)=="0") {
information = giftinfo.split(",");
x = document.write("<td>",information[4],"</td>");
x = document.write("<td>",information[5],"</td>");
x = document.write("<td>",information[9],"</td>");
x = document.write("</tr>");
}
}
while (!gift.AtEndOfStream);

x = document.write("</table>");

</script>

However it doesn't work from a server using IE. From what I've read I
believe it is because the filesystemobject works with the local filesystem
whereas the csv file is on the server.

Is there any way of redoing this so that the file on the server is opened
and read, or can I download the csv file onto the client machine so that it
works as written, or do I need to be doing something with asp (is that
right?) so the the scripting runs on the server not the client?

Or am I asking the wrong questions?

Jul 23 '05 #1
1 1593
Malcolm wrote:
However it doesn't work from a server using IE. From what I've read I
believe it is because the filesystemobject works with the local filesystem
whereas the csv file is on the server.
Correct.
Is there any way of redoing this so that the file on the server is opened
and read,
Not really.
or can I download the csv file onto the client machine so that it
works as written,
Nope.
or do I need to be doing something with asp (is that
right?)
Well, it can solve your problem, but not the way you are trying to solve it now.
so the the scripting runs on the server not the client?
No.
Or am I asking the wrong questions?


Basically. You can't "open and read" an http resource. What you *can* do is load
it into a hidden <iframe>, then parse the results using client-side JavaScript.
You could also use the XML HTTP Request object <url:
http://jibbering.com/2002/4/httprequest.html /> to request and parse the .csv
file.

However, the easiest thing to do is have ASP generate client side JavaScript
that sets things up the way you want:

<%
// read the file
// Response.write something that outputs the code shown below:
// <script type="text/javascript">
// var theCSVFile = [
// [ row1value1, row1value2, row1value3 ],
// [ row2value1, row2value2, row2value3 ],
// // etc
// ];
// </script>
%>

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq

Jul 23 '05 #2

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

Similar topics

3
by: Nick Bunton | last post by:
I have setup remote debugging on an NT4 workstation for testing. I then build from the debug config on my machine and copy all the files from the /bin/debug folder including the .PDB files. I then...
9
by: Etienne Charland | last post by:
Hi, there is an application running on a remote desktop (under Citrix ICA, but the same problem applies for RDC or PC Anywhere). Now, I want to send keys to the remote application from a local app....
5
by: GEL | last post by:
Hi, I want to open a new browser window, let the user use that window for several minutes, and when they close, I'd like to change the page displayed in the original window. According to...
3
by: Elp | last post by:
Hi, I have developped a Windows applcation (in C#) that allows, among other things, users to view and control the desktop of a remote Windows XP Pro machine. I have actually simply embedded the...
15
by: JJ | last post by:
A current requirement I am facing is the all business objects be stateless remote components hosted in IIS. I am partial to web services myself. However, it is insisted that IIS hosted remoting be...
0
by: matvdl | last post by:
My asp.net application depends on obtaining allot of data from a remote application. This application is a bit of a monster and it is not an option to install it on the asp.net system. Note - the...
3
by: STom | last post by:
If I am moving a file with the FileSystemObjects move command, will the code not move to the next process until the file has completely finished being moved? I just want to make sure that the file...
7
by: | last post by:
I'm writing an ASP.NET app, using Visual Studio 2003. VS is running locally on my laptop, but the web app is running on a remote server. My laptop is not in the domain. I do have a domain account....
5
by: idorjee | last post by:
hi guys, I'm trying to figure how to read a file from my other computer, and here is what i did. it doesn't work for some reason. i would really appreciate if you could help me with this. i get...
3
by: Yves Gagnon | last post by:
Hi, I try to debug a WCF hosted in a windows services on a serveur that is on an other domaine then my developpement machine. I tried many things without succes. Here is what I tried: First I...
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: 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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
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
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,...
0
isladogs
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...

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.