ASPvbscript - Reading Binary Files

Results 1 to 2 of 2

Thread: ASPvbscript - Reading Binary Files

  1. #1
    HopinGator Guest

    Default ASPvbscript - Reading Binary Files

    I am trying to read a binary file that contains a Single precision floating point number. It appears only reading text files is possible with standard ASP objects. So...i tried to read it as text.<BR><BR>My file has the first 4 bytes 00:A0:BE:45 ( This is 6100 in single precision floating point)<BR><BR>I use the objTSO.Read(4) function to read the first 4 characters.<BR><BR>Ultimately I want to be able to Display 6100 to the screen.<BR><BR>tmpString = objTSO.Read(4) &#039 - Variant of subtype String<BR>tmpNumber = CSng(tmpString) &#039 - vbscript error <BR>Respsonse.Write "Value = " & tmpNumber &#039 - should display 6100<BR><BR>Thanks for any help,<BR>HopinGator

  2. #2
    Join Date
    Dec 1969

    Default RE: ASPvbscript - Reading Binary Files

    Try prefixing your 4 byte string with "&H" before doing CSng - this should tell it to interpret the string as Hex instead of decimal - eg:<BR><BR>tmpNumber = CSng("&H" & tmpString)<BR><BR>If this doesn&#039t work you need to check exactly what tmpString contains in order to decide how to deal with it.<BR><BR>Dunc

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts