Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.