🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.oberon
Article #718

Oberon/F:Memory functions?

#718
From: Ivan Posva
Date: Mon, 18 Dec 1995 14:40
56 lines
2387 bytes
> What is the mechanism to init memory locations (i.e. record structures).  In
> Turbo Pascal it was FILLCHAR(<struc>,<Len>,<fillcharacter>). (SETMEM in C I
> believe).  For the <Len> paramater, you could also use a built in Turbo
> PASCAL function:
> 
> SIZEOF(<struc>),
> 
> Does Oberon/F have equivalents for these two Turbo functions?

Hi,

All pointers are automatically initialized to NIL in Oberon. Other fields
in records must usually be set by the programmer to the desired value
individually. The following commented module should give you examples.

MODULE Records;

TYPE
  Ptr = POINTER TO Rec;
  Rec = RECORD
    a, b: INTEGER;
    p: Ptr;
  END;

VAR
  rec: Rec; (* At least the field p of rec is initialized to NIL when the
               module loads, usually all space allocated to global variables
               is set to zero (depends on implementation). *)

  PROCEDURE Proc;
    VAR r: Rec; p: Ptr;
    (* The field p of the record variable r is initialized to NIL, and the
       pointer variable p is initialized to NIL *)
  BEGIN
    NEW(p); (* The field p of the record that p is pointing to, is set to
	             NIL. Depending on the implementation the whole structure is
               set to zero. *)
  END Proc;

  PROCEDURE Sizeof*;
    VAR i: INTEGER;
  BEGIN
    i := SIZE(Rec); (* Giving 8 for this example on the Oberon/F for
                       Macintosh (68K). *)
  END Sizeof;
  
END Records.


-Ivan
====================================================================
Ivan Posva                                 Oberon microsystems, Inc.
posva@oberon.ch                                  Technoparkstrasse 1
voice ++41-1-445-1751                                 CH-8005 Zurich
fax   ++41-1-445-1752             http://www.oberon.ch/Customers/omi
====================================================================
Technical Details
Message-ID: <199512181436.PAA12680@lillian.inf.ethz.ch>
Path: arc1-ca.pugleaf.net!inf.ethz.ch!oberon-news@inf.ethz.ch

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!inf.ethz.ch!oberon-news@inf.ethz.ch
From: posva@oberon.ch (Ivan Posva)
Newsgroups: comp.lang.oberon
Subject: Oberon/F:Memory functions?
Date: 18 Dec 1995 15:40:25 +0100
Organization: Dept. Informatik, Swiss Federal Institute of Technology
Sender: server@inf.ethz.ch
Distribution: world
Message-ID: <199512181436.PAA12680@lillian.inf.ethz.ch>
Reply-To: oberon-news@inf.ethz.ch
NNTP-Posting-Host: neptune.inf.ethz.ch
Originator: oberon-news@inf.ethz.ch