🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.modula2
8 messages
8 total messages Started by Ronald Snelgrove Sun, 17 Mar 1996 04:13
SIZE function for FST (DOS) compiler?
#3379
Author: Ronald Snelgrove
Date: Sun, 17 Mar 1996 04:13
10 lines
973 bytes
To anyone using the Fitted Software Modula-2 compiler for DOS:
  I have already looked through all of the definition modules for this and
couldn't find it, so I'm hoping that I have just missed it.  I was wondering
if there was a function that when given a data type, would return  the number
of bytes required to store that type, ie SIZE(INTEGER) would return 2.  This
would be the equivalent to the TSIZE function on the Macintosh MetroWerks
compiler, if that helps anyone.  

							Thanks
							  Ron
Re: SIZE function for FST (DOS) compiler?
#3381
Author: Jeffrey E Stoner
Date: Mon, 18 Mar 1996 05:45
18 lines
1329 bytes
Ronald Snelgrove (ronald@newton.physics.BrockU.CA) wrote:
: To anyone using the Fitted Software Modula-2 compiler for DOS:
:   I have already looked through all of the definition modules for this and
: couldn't find it, so I'm hoping that I have just missed it.  I was wondering
: if there was a function that when given a data type, would return  the number
: of bytes required to store that type, ie SIZE(INTEGER) would return 2.  This
: would be the equivalent to the TSIZE function on the Macintosh MetroWerks
: compiler, if that helps anyone.  

Well, in the manual, pages 21-22 lists the amount of storage for each data
type.  Simply count 'em up.

Jeff

-- 
   *  internet-->  jesst63+@pitt.edu             * This space reserved  *
   *  http://www.pitt.edu/~jesst63               * for something much   *
   * "I am outcast, unclean." - Thomas Covenant  * better to come along *
Re: SIZE function for FST (DOS) compiler?
#3385
Author: Georg Lokowandt
Date: Mon, 18 Mar 1996 14:38
34 lines
1998 bytes
In article <4iitag$ai7@usenet.srv.cis.pitt.edu> jesst63+@pitt.edu (Jeffrey E Stoner) writes:
>Ronald Snelgrove (ronald@newton.physics.BrockU.CA) wrote:
>: To anyone using the Fitted Software Modula-2 compiler for DOS:
>:   I have already looked through all of the definition modules for this and
>: couldn't find it, so I'm hoping that I have just missed it.  I was wondering
>: if there was a function that when given a data type, would return  the number
>: of bytes required to store that type, ie SIZE(INTEGER) would return 2.  This
>: would be the equivalent to the TSIZE function on the Macintosh MetroWerks
>: compiler, if that helps anyone.  

Just import the functions SIZE and/or TSIZE from the Pseudo-Module SYSTEM (not System).
I don't have the differences at hand, but they both exist.


>
>Well, in the manual, pages 21-22 lists the amount of storage for each data
>type.  Simply count 'em up.

Please don't do that, your programm will get very machine and compiler dependent

>
>Jeff
>
>-- 
>   *  internet-->  jesst63+@pitt.edu             * This space reserved  *
>   *  http://www.pitt.edu/~jesst63               * for something much   *
>   * "I am outcast, unclean." - Thomas Covenant  * better to come along *

Georg
-- 
Georg Lokowandt  phone: 0711-7816-208  fax: 0711-7816-340
e-mail: lokowand@dia.informatik.uni-stuttgart.de
mail: Universitaet Stuttgart
      Breitwiesenstr. 20-22    70565 Stuttgart    Germany
Re: SIZE function for FST (DOS) compiler?
#3392
Author: Peter Moylan
Date: Mon, 18 Mar 1996 21:55
21 lines
1556 bytes
Ronald Snelgrove (ronald@newton.physics.BrockU.CA) wrote:
>To anyone using the Fitted Software Modula-2 compiler for DOS:
>  I have already looked through all of the definition modules for this and
>couldn't find it, so I'm hoping that I have just missed it.  I was wondering
>if there was a function that when given a data type, would return  the number
>of bytes required to store that type, ie SIZE(INTEGER) would return 2.  This
>would be the equivalent to the TSIZE function on the Macintosh MetroWerks
>compiler, if that helps anyone.  

I haven't checked the FST features lately; but both SIZE(variable)
and TSIZE(type) are in the language.  You can import them from
SYSTEM.  If these are missing, it's a compiler bug.

You won't find them in a definition module, though.
They're built-in functions, not library functions.

--
Peter Moylan                           peter@ee.newcastle.edu.au
                  http://www.eng.newcastle.edu.au/ee/Moylan.html
OS/2 freeware list at 
      http://www.eng.newcastle.edu.au/ee/Moylan/os2/os2info.html
Re: SIZE function for FST (DOS) compiler?
#3397
Author: Pat Terry
Date: Tue, 19 Mar 1996 14:56
9 lines
876 bytes
In article <4ijsgq$3ct@zdi.informatik.uni-stuttgart.de> lokowand@dia.informatik.uni-stuttgart.de (Georg Lokowandt) writes:

>Just import the functions SIZE and/or TSIZE from the Pseudo-Module SYSTEM (not System).
>I don't have the differences at hand, but they both exist.

SIZE is pervasive (or should be) - no need for an import.
SYSTEM.TSIZE needs an import.

They are basically similar.
Re: SIZE function for FST (DOS) compiler?
#3407
Author: Graham Perkins
Date: Thu, 21 Mar 1996 15:32
41 lines
2437 bytes
Jeffrey E Stoner wrote:
> Ronald Snelgrove (ronald@newton.physics.BrockU.CA) wrote:
> : To anyone using the Fitted Software Modula-2 compiler for DOS:
> : of bytes required to store that type, ie SIZE(INTEGER) would return 2.  This
> 
> Well, in the manual, pages 21-22 lists the amount of storage for each data
> type.  Simply count 'em up.
> 

No, no!  That won't help!  He is trying to write software that does
some stuff regardless of what size the data item is.  OK so he could
count up and use a numeric literal, but then the software would need
changing in lots of places if the data item ever changed.  And the
compiler won't check you've made all those changes.  And the runtime
might not show any obvious faults for a while.

I needed that SIZE function for my file handling modules I just
wrote.  The definition module contains 

  TYPE Item = INTEGER; (* or any other transparent type *)
       Key  = INTEGER; (* or any other transparent type *)

so clients can make their own copies of the module, putting whatever
record and key structures they like.  They don't need to touch the
rest of the def. module or any of the imp. module.  Buried away in
the imp. module are a load of SIZE(Item) calls needed to cope with
all that low level "ReadNBytes" stuff.  

I can make this (and sequential and relative files) work for Topspees,
Gardens Point, and Logitech.  But it looks like it wouldn't be possible
for Fitted Software.

Ronald might like to try writing his own SIZE function, but I think
the only way would be via a paremeter of type ARRAY OF BYTE and I'm
not sure if Fitted Software M2 supports that.

-- 
person: Graham Perkins         paper: School of Computing
voice:  +44 (0)1908 834936            De Montfort University
dots:   +44 (0)1908 834948            Milton Keynes MK7 6HP
bits:   grp@dmu.ac.uk                 United Kingdom
Re: SIZE function for FST (DOS) compiler?
#3408
Author: Martin Whitaker
Date: Thu, 21 Mar 1996 18:05
19 lines
1425 bytes
In article <1996Mar17.041332.11054@spartan.ac.BrockU.CA>, ronald@newton.physics.BrockU.CA (Ronald Snelgrove) writes:
> To anyone using the Fitted Software Modula-2 compiler for DOS:
>   I have already looked through all of the definition modules for this and
> couldn't find it, so I'm hoping that I have just missed it.  I was wondering
> if there was a function that when given a data type, would return  the number
> of bytes required to store that type, ie SIZE(INTEGER) would return 2.  This
> would be the equivalent to the TSIZE function on the Macintosh MetroWerks
> compiler, if that helps anyone.  
> 
Both SIZE and TSIZE are part of the language as defined by Wirth, and should be
available in the pseudo-module SYSTEM. Try putting

FROM SYSTEM IMPORT SIZE, TSIZE;

in your module. SIZE returns the storage size of a variable, TSIZE the storage
size of a type. All the Modula-2 compilers I have used have provided these, so
I would be surprised if Fitted Software Modula-2 did not.

Martin
Re: SIZE function for FST (DOS) compiler?
#3409
Author: Pat Terry
Date: Fri, 22 Mar 1996 12:45
9 lines
856 bytes
In article <31517683.793C@dmu.ac.uk> Graham Perkins <grp@dmu.ac.uk> writes:

>I can make this (and sequential and relative files) work for Topspees,
>Gardens Point, and Logitech.  But it looks like it wouldn't be possible
>for Fitted Software.

FST _does_ support SIZE.  And even if it didn't you could use SYSTEM.TSIZE.

Actually my recollection is that on TSIZE is in Logitech, not SIZE.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads