🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #3440

Re: SIZE function for FST

#3440
From: WILL BURROW
Date: Sat, 30 Mar 1996 20:22
77 lines
2995 bytes
  Graham Perkins,
  In a message on 21 March, wrote :

GP> Jeffrey E Stoner wrote:
GP> > Ronald Snelgrove (ronald@newton.physics.BrockU.CA) wrote:
GP> > : To anyone using the Fitted Software Modula-2 compiler for DOS:
GP> > : of bytes required to store that type, ie SIZE(INTEGER) would return 2
GP> s
GP> > 
GP> > Well, in the manual, pages 21-22 lists the amount of storage for each d
GP> > type.  Simply count 'em up.
GP> > 
GP> 
GP> No, no!  That won't help!  He is trying to write software that does
GP> some stuff regardless of what size the data item is.  OK so he could
GP> count up and use a numeric literal, but then the software would need
GP> changing in lots of places if the data item ever changed.  And the
GP> compiler won't check you've made all those changes.  And the runtime
GP> might not show any obvious faults for a while.
GP> 
GP> I needed that SIZE function for my file handling modules I just
GP> wrote.  The definition module contains 
<snip>
GP> the imp. module are a load of SIZE(Item) calls needed to cope with
GP> all that low level "ReadNBytes" stuff.  
GP> 
GP> I can make this (and sequential and relative files) work for Topspees,
GP> Gardens Point, and Logitech.  But it looks like it wouldn't be possible
GP> for Fitted Software.
GP> 
GP> Ronald might like to try writing his own SIZE function, but I think
GP> the only way would be via a paremeter of type ARRAY OF BYTE and I'm
GP> not sure if Fitted Software M2 supports that.

What is broken?
The following program works (see output below):


MODULE Testaofb;

FROM InOut IMPORT WriteCard, WriteString, WriteLn;
FROM SYSTEM IMPORT BYTE;

PROCEDURE Passaofb( x: ARRAY OF BYTE );
BEGIN
    WriteCard( SIZE( x ), 5 );
END Passaofb;

VAR n: INTEGER;
    s: ARRAY [0..10] OF CHAR;
    l: LONGCARD;
BEGIN
    WriteString("              INTEGER: ");    Passaofb( n );
    WriteString("  ");  WriteCard( SIZE( n ), 5 );
    WriteLn;

    WriteString("ARRAY [0..10] OF CHAR: ");    Passaofb( s );
    WriteString("  ");  WriteCard( SIZE( s ), 5 );
    WriteLn;

    WriteString("             LONGCARD: ");    Passaofb( l );
    WriteString("  ");  WriteCard( SIZE( l ), 5 );
    WriteLn;
END Testaofb.

Output is as follows:

              INTEGER:     2      2
ARRAY [0..10] OF CHAR:    11     11
             LONGCARD:     4      4

Perhaps you are refering to opaque types or something?

Will.
  
...
 * ATP/Linux 1.42 * and now Jeanette MacDonald with "Beyond the Blue Horizon"
Technical Details
Message-ID: <8BDB322.0135000271.uuout@tad.com>
Path: arc1-ca.pugleaf.net!scratchy.mi.net!tad!will.burrow
References: <31517683.793C@dmu.ac.uk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!scratchy.mi.net!tad!will.burrow
From: will.burrow@tad.com (WILL BURROW)
Newsgroups: comp.lang.modula2
Subject: Re: SIZE function for FST
Message-ID: <8BDB322.0135000271.uuout@tad.com>
Date: Sat, 30 Mar 96 13:22:00 -0700
Distribution: world
Organization: TRANS ATLANTIC DIMENSIONS
Reply-To: will.burrow@tad.com (WILL BURROW)
References: <31517683.793C@dmu.ac.uk>
X-Newsreader: PCBoard Version 15.22
X-Mailer: PCBoard/UUOUT Version 1.20