PDA

View Full Version : Searching for info.


hughesmi
11-16-2002, 12:15 PM
Problem I'm a Dj, and now my CD collection is now to large for me to remember location of songs.

I'm looking for a way to use JS to search certain information on a web page or maybe a txt file.? I have tried several database programmes, but the wee laptop I use is old and only has ms office 97 on it. So as my last resort, I was hoping for JavaScript as a Solution.

If anyone can help, this a search criteria I would need.
i.e

Tile of Cd
Title of Song
Track Number
Case Number and Pocket Number.

beetle
11-16-2002, 04:24 PM
You can use ActiveX to read files from a local machine...perhaps even txt files. I don't have any experience in this area, so I'm afraid these are the extent of my comments.

Graeme Hackston
11-16-2002, 09:15 PM
Beetle is right, you can use activeX to search txt files. It's actually quite powerful because you can read and write to js files as well. You can, for instance, update an external array with new file names. I've yet to get my head around all the possibilities of altering js files. Obviously changes to js files won't take effect until the next time the search page is loaded.

I asked a question recently that uses this type of coding, here is the link:

http://www.codingforums.com/showthread.php?s=&threadid=9589

Updating an external array is how I got around the code in the link above throwing an error if a file didn't exist.

ConfusedOfLife
11-16-2002, 09:44 PM
I read your post ( the link that you provided ) and like lots of ppl ( not actually lots of them! ) I don't know how to work with this active-x and connect/make some components to/for my scripts. any link/resource/somethin?!

Graeme Hackston
11-16-2002, 10:12 PM
I didn't really find lots of info on it. Everything I found was at the MS site but I'll be darned if I can find the link.

Here is a save and delete test page I made, hopefully this will help. Save, delete and read (for read see the thread I started) are the extent of my knowledge. Change the file path to something that suits you.

<html>
<head>
<title></title>
<script>

function go() {

var TristateFalse = 0;
var ForWriting = 2;

SaveFile = new ActiveXObject("Scripting.FileSystemObject");
thepage = "c:\\My Documents\\test.htm"
thecontent = "some content"
SaveFile.CreateTextFile(thepage);
a = SaveFile.GetFile(thepage);
b = a.OpenAsTextStream(ForWriting, TristateFalse);
b.Write(thecontent);
b.Close();

alert('function stopped, go check file, come back and click "ok", then re-check')

DeleteFile = new ActiveXObject("Scripting.FileSystemObject");
c = DeleteFile.GetFile(thepage);
c.Delete();
}

</script>
</head>
<body>
<a href="#" onClick="go()">go</a>
</body>
</html>

Graeme Hackston
11-16-2002, 10:17 PM
Just a warning, be careful with the file path because it will write over anything without warning (after the alert is accepted)

Graeme Hackston
11-16-2002, 11:12 PM
Found a link

http://www.webreference.com/js/tips/001031.html

whammy
11-16-2002, 11:28 PM
Couldn't you use XML and parse that?

http://www.w3schools.com/xml/xml_parser.asp

hughesmi
11-18-2002, 03:21 PM
Thank's for all the advice on my top post. but this gone just a bit over my head.

Would a hta files would be soiltion to my problem?

As I say all I need is a way to search for info' and a way to add info. read and write......

ConfusedOfLife
11-18-2002, 07:44 PM
Thanx Graeme, the link is cool, I would have written my URLBook (http://www.irandiba.net/confusedoflife/URLBook/) with this if I knew it earlier!

Graeme Hackston
11-19-2002, 12:29 AM
Glad you got it. Judging by your link you'll have fun with it.

hughesmi I don't know anything about hta files. If you want to try with JS/activeX this page will help.

http://www.devguru.com/Technologies/ecmascript/quickref/string.html

Graeme Hackston
11-19-2002, 12:55 AM
Just a note. The test page I posted above has unneeded code. This works just as well.

<html>
<head>
<title></title>
<script>
fso = new ActiveXObject("Scripting.FileSystemObject");

function go() {

var TristateFalse = 0;
var ForWriting = 2;

thepage = "c:\\My Documents\\test.htm"
thecontent = "some content"
fso.CreateTextFile(thepage);
a = fso.GetFile(thepage);
b = a.OpenAsTextStream(ForWriting, TristateFalse);
b.Write(thecontent);
b.Close();

alert('function stopped, go check file, come back and click "ok", then re-check')


c = fso.GetFile(thepage);
c.Delete();
}

</script>
</head>
<body>
<a href="#" onClick="go()">go</a>
</body>
</html>

whammy
11-19-2002, 01:14 AM
Yeah, if it's a local file and you're using windows, using FSO (Scripting.FileSystemObject) with ActiveX should solve your problems.

I might just skip the whole browser bit and use a .vbs file myself though. :)

http://www.w3schools.com