Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 10th, 2003, 12:58 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

If it is a stream then you can use adodb.stream class. Write the data received to it, set the character set and read back as text.



--

Joe
 
Old November 10th, 2003, 01:41 PM
Authorized User
 
Join Date: Jul 2003
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to stalker Send a message via MSN to stalker
Default

I had already worked with Streams.

I did the normal procedure. This is not the exact code but it was something like this.

teste = new ActiveXObject("ADODB.Stream");
teste.Type = 1;
teste.Open();
teste.Write(resposta.ResponseBody);
teste.Type = 2;
teste.Charset = "ascii"
teste.Position = 0;
teste2 = teste.Read()


I cannot handle the Stream yet!
1) I set it as binary (coz binary is the only data I know that is correct).
2) Opened the Stream
3) Shoved the binary array

Everything ok till here! I checked with the Script Editor of MSFrontPage.

4) Tried to chage it back to Text. But it returns error here!
5) Would then set the charset to iso latin-1.
6) Would read the text with the correct ISO.

Do you know how to convert binary data inside a Stream into text?

Thx!

 
Old November 10th, 2003, 01:56 PM
Authorized User
 
Join Date: Jul 2003
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to stalker Send a message via MSN to stalker
Default

AH!!! I did IT!!

ehehe

I just had to change the Position property to 0 [u]before</u> converting the Stream back to TEXT!

It's ok now!!

Thanks for your quite responses man! this was like MIRC chatting! :)

 
Old November 10th, 2003, 02:09 PM
Authorized User
 
Join Date: Jul 2003
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to stalker Send a message via MSN to stalker
Default

OK for future use to other guys this is the final code:
This script gets any Text file from a remote server anyware and saves it into a file in your hard drive.

The function:
function GetNewData(address,fileloc) {
    var objFSO, resposta, temp, TextFile;

    try {
        temp = new ActiveXObject("ADODB.Stream");
        objFSO = new ActiveXObject("Scripting.FileSystemObject");
        resposta = new ActiveXObject("Msxml2.XMLHTTP");
        TextFile = objFSO.CreateTextFile(fileloc);

        resposta.open("GET",address,false);
        resposta.send();

        temp.Type = 1;
        temp.Open();
        temp.Write(resposta.ResponseBody);
        temp.Position = 0;
        temp.Type = 2;
        temp.Charset = "ascii";

        TextFile.write(temp.ReadText());
        temp.Close()
        TextFile.Close();
    }
    catch(e){
        alert("Failure while updating the DataBase!\nDescription: "+e.description);
        return;
    }
}


The Caller:
GetNewData("http://someserver/yourpage.html" , "c:\\yourfolder\\yourfile.EXT");

OK! That's All Folks! :)

 
Old April 29th, 2004, 05:06 AM
Registered User
 
Join Date: Apr 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, that was just the push I needed.

When I changed the Charset to "iso-8859-1", I could save the verbatim file sent by the server, in my case a JPG image.

/RS






Similar Threads
Thread Thread Starter Forum Replies Last Post
server error when uploading to remote server ammweb ASP.NET 1.0 and 1.1 Basics 7 July 30th, 2006 01:51 AM
VB Express and SQL server on remote server questio HoosierDaddy61 Visual Basic 2005 Basics 0 February 22nd, 2006 11:27 AM
connecting web server and remote db server via asp moreyt Classic ASP Databases 0 May 31st, 2005 12:13 AM
Linking Remote Sql Server with Web server yeetesh Pro VB Databases 1 May 26th, 2005 04:13 AM
connecting to remote server moushumi SQL Server 2000 3 March 29th, 2004 07:52 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.