VoyForums
[ Show ]
Support VoyForums
[ Shrink ]
VoyForums Announcement: Programming and providing support for this service has been a labor of love since 1997. We are one of the few services online who values our users' privacy, and have never sold your information. We have even fought hard to defend your privacy in legal cases; however, we've done it with almost no financial support -- paying out of pocket to continue providing the service. Due to the issues imposed on us by advertisers, we also stopped hosting most ads on the forums many years ago. We hope you appreciate our efforts.

Show your support by donating any amount. (Note: We are still technically a for-profit company, so your contribution is not tax-deductible.) PayPal Acct: Feedback:

Donate to VoyForums (PayPal):

Login ] [ Contact Forum Admin ] [ Main index ] [ Post a new message ] [ Search | Check update time | Archives: 12[3] ]


[ 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:

<a rel=nofollow target=_blank href="http://home4u.hongkong.com/entertainment/music/mpx/js/httpget/HTTPGet.htm">http://home4u.hongkong.com/entertainment/music/mpx/js/httpget/HTTPGet.htm</a>

It is available for download at:

<a rel=nofollow target=_blank href="http://home4u.hongkong.com/entertainment/music/mpx/js/httpget/httpget.zip">http://home4u.hongkong.com/entertainment/music/mpx/js/httpget/httpget.zip</a>

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: 3.00b, ConfDB:
Before posting please read our privacy policy.
VoyForums(tm) is a Free Service from Voyager Info-Systems.
Copyright © 1998-2019 Voyager Info-Systems. All Rights Reserved.