[Javascript] Converting to string data...better explanation of the problem...

Peter Brunone peter at brunone.com
Wed May 2 15:51:41 CDT 2001


    Have you tried Response.BinaryWrite ?

    Unless I miss my guess, you're using ASP commands in here; you might
have more success on some of the lists at www.asplists.com .

----- Original Message -----
From: "Carlos" <carlos at unica.cu>
To: "Javascript List" <javascript at LaTech.edu>
Sent: Wednesday, May 02, 2001 4:39 PM
Subject: [Javascript] Converting to string data...better explanation of the
problem...


> I want to convert a variant data into a string, because I have to print
it,
> in others words I read a binary file, and I want to print the content of
the
> file. The code works prefectly (no errors messages), but the result is not
> what I desire...here is the code...
>
> function Load(FileName) {
> var BinFile, BinData;
>     BinFile = Server.CreateObject("ADODB.Stream");
>     BinFile.Open();
>     BinFile.LoadFromFile(FileName);
>     BinFile.Type = adTypeBinary;
>     BinData = BinFile.Read();
>     BinFile.Close();
>     BinFile = null;
>     Response.Write(BinData);
> }
>
> according to all references I've read, the function Stream.Read(numBytes)
> reads numBytes from a stream and return the data as a Variant, but I can't
> find that type (Variant) in any place of my Javascript's Tutorial, and I
> need to convert it to a string to display it, cause the sentence
> "Response.Write(BinData)" only displays "????" symbols...
> How can I convert it to a string??? In extension,: how can I convert it to
> any data???, for example to an Integer?...I mean:
>
> BinData = BinFile.Read(1);
>
> and after this convert BinData to and Integer...
>
> Thanks
> Carlos
>
> PD: I want to warning, that if the file the function is loading is a text
> file, and I replace the lines:
>     BinFile.Type = adTypeBinary;
>     BinData = BinFile.Read();
> by...
>     BinFile.Type = adTypeText;
>     BinData = BinFile.ReadText();
> it works perfectly, but I don't want to do so, I want to read the file as
a
> binary file.
>
>
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> http://www.LaTech.edu/mailman/listinfo/javascript
>





More information about the Javascript mailing list