Creating BINARY FILES - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Creating BINARY FILES

Hi programmers,

Since BINARY files are more compact and byte-effective compare to text files, I would like to create BINARY file having values ranging from -4500 to 4500. They are all integer values. I wouldn't mind if the programme can handle float, integer and character values.
Thank you very much.

Bolaji Aliu


URL:http://www.cgiar.org/iita

Comments

  • : Hi programmers,
    :
    : Since BINARY files are more compact and byte-effective compare to text files, I would like to create BINARY file having values ranging from -4500 to 4500. They are all integer values. I wouldn't mind if the programme can handle float, integer and character values.
    : Thank you very much.
    :
    : Bolaji Aliu
    :
    Hi,

    Below is a program to first put several integers in a file and then read them
    REM Write the integers.
    DEFINT A
    OPEN "c:qb45ina3.txt" FOR BINARY AS #1
    CLS
    DATA 4500,12,45,1254,3681,-2340,-45,68,-4010,9999

    DO
    READ a
    PUT #1, , a
    LOOP WHILE a <> 9999
    CLOSE #1

    REM Read the integers.
    OPEN "c:qb45ina3.txt" FOR BINARY AS #1
    CLS

    DO
    GET #1, , a
    PRINT a
    LOOP WHILE a <> 9999

    CLOSE #1

    Hope this helps.
    BTW Each integer takes up two bytes instead of a possable 6 for a number like -4234 in a text file.

    Dick


Sign In or Register to comment.