VoyForums

VoyUser Login optional ] [ Contact Forum Admin ] [ Main index ] [ Post a new message ] [ Search | Check update time | Archives: [1] ]


[ Next Thread | Previous Thread | Next Message | Previous Message ]

Date Posted: 22:19:41 09/17/99 Fri
Author: Webmaster
Subject: Re: How to get something inside this file?
In reply to: daihao 's message, "How to get something inside this file?" on 09:39:08 09/13/99 Mon

Hi, daihao.

Sorry for my late response. I've uploaded a demonstration of how to use Javascript, with the help of Java applet, to read a file on a web server:

http://home4u.hongkong.com/entertainment/music/mpx/js/httpget/HTTPGet.htm

It is available for download at:

http://home4u.hongkong.com/entertainment/music/mpx/js/httpget/httpget.zip

After finish loading the Java applet, the content of the file "HTTPGet.htm" is displayed in the textarea. The content can be stored in a string for string operation. The file to be read must be in the same directory of the applet class file.

1) We can seek the character of ASCII code 0A to count the number of line since each line ends with this character. Use the following function to get the character:

unescape("%0A")

So the 1st character of the 3rd line is next to the 2nd "%0A" character. It is easy to get the position of the 5th character in the 3rd line using "indexOf" string method.

2) As the file content is stored in a string, you can use "indexOf" to see if a word is inside the file. If the word doesn't exist, the method returns -1 (minus one).

I hope this helps.

Thank you for your visit.



> 1. How to get something inside the same file, eg line
> 3, char 5?
> 2. How can we know whether a word or character is
> inside this file?

[ Next Thread | Previous Thread | Next Message | Previous Message ]


Replies:


[ Contact Forum Admin ]


Forum timezone: GMT-8
VF Version: 2.94, ConfDB:
Before posting please read our privacy policy.
VoyForums(tm) is a Free Service from Voyager Info-Systems.
Copyright © 1998-2008 Voyager Info-Systems. All Rights Reserved.