🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #3046

Re: binary IO in M2

#3046
From: Martin Rand
Date: Sat, 18 Nov 1995 06:58
34 lines
1440 bytes
dcollier@cix.compulink.co.uk ("David Collier") wrote:

>Binary IO in M2...

>How about something like ( JPI anyway ):

>TYPE RealBinaryType = ARRAY [ 0 .. SIZE(REAL) - 1 ] OF BYTE ;

>VAR F : REAL ;

>PROCEDURE WriteRealInBinary(  ..... RealNumber : REAL ) ;
>BEGIN
>FIO.WrBin(File , RealBinaryType( RealNumber ) , Size( RealBinaryType )) ;
>END WriteRealInBinary ;
>________

>Sorry, lots of details missing, it's late. But the tools are all very 
>simple.

>Of course it is easier if you can write/read complete records, with all 
>the fields set up. It becomes one call to FIO for lots of variables.

But in JPI you don't need to do that! ARRAY OF BYTE is
assignhment-compatible with *anything*. So you just need to (in your
example):

FIO.WrBin(File, F);

and so on for any other type, structured or not.


Martin Rand            | Tel: (44) 1703 252445 |
Highfield Software Ltd | Fax: (44) 1703 252445 |
Southampton, UK        |                       |
Technical Details
Message-ID: <48k09m$hs7@zeus.tcp.co.uk>
Path: arc1-ca.pugleaf.net!tcp.co.uk!usenet
References: <DI4zvy.19A@liverpool.ac.uk> <DI6L4D.F0@cix.compulink.co.uk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!tcp.co.uk!usenet
From: hsl@tcp.co.uk (Martin Rand)
Newsgroups: comp.lang.modula2
Subject: Re: binary IO in M2
Date: Sat, 18 Nov 1995 06:58:54 GMT
Organization: Total Connectivity Providers - Internet access for the UK
Message-ID: <48k09m$hs7@zeus.tcp.co.uk>
References: <DI4zvy.19A@liverpool.ac.uk> <DI6L4D.F0@cix.compulink.co.uk>
Reply-To: hsl@tcp.co.uk
NNTP-Posting-Host: du1-42.tcp.co.uk
X-Newsreader: Forte Free Agent 1.0.82