-> oberon-1 style OOP

<-------------------------------------------------

MODULE ooptest; 
IMPORT 
        Out; 


TYPE  T = RECORD x, y:  INTEGER  END; 
TYPE 
   T0 = RECORD (T) z: REAL END;  (* extension of T *) 
   T1 = RECORD (T) w: LONGREAL END; (* extension of T *) 
TYPE 
    action  = PROCEDURE (a,b: INTEGER): INTEGER; (* a procedural type 
*) 
    T2 = RECORD (T) 
          Add: action   (*  "Add" is a "method" of the T2 class *) 
        END; 


VAR 
  object: T2; result: INTEGER; 


PROCEDURE AddIt(a, b : INTEGER): INTEGER; 
BEGIN 
        RETURN a + b; 
END AddIt; 


PROCEDURE Do*; 
BEGIN 
        Out.Int(result, 5); 
        Out.Ln(); 
END Do; 


BEGIN 
  object.x := 123; object.y := 456; object.Add := AddIt; 
  result := object.Add (object.x, object.y); (* method call *) 
END ooptest.

--------------------------------------------------------->



ULM's oberon system
-------------------

-> how to work with pipes

PipeExample.om
<---
MODULE PipeExample;

   IMPORT RelatedEvents, Streams, UnixPipes;

   PROCEDURE DoIt;
      VAR
         pipe: Streams.Stream;
   BEGIN
      IF UnixPipes.Open(pipe, "ls -al",
            UnixPipes.read, Streams.onebuf,
            RelatedEvents.null) THEN
         IF ~Streams.Copy(pipe, Streams.stdout, -1) THEN
            (* error case: either reading from the pipeline
               or writing to Streams.stdout failed
            *)
         END;
         Streams.Release(pipe);
      ELSE
         (* error case: could not open pipeline *)
      END;
   END DoIt;
BEGIN
   DoIt;
END PipeExample.
--->

PipeExample.od

<---
DEFINITION PipeExample;
END PipeExample.
--->

PipeExammple2.om

<---
MODULE PipeExample2;

   IMPORT Conclusions, Errors, RelatedEvents, Streams, UnixPipes;

   PROCEDURE DoIt;
      VAR
         pipe: Streams.Stream;
         errors: RelatedEvents.Object;
   BEGIN
      NEW(errors); (* create an object all error events will be related to *)
      RelatedEvents.QueueEvents(errors); (* collect all error events *)
      IF UnixPipes.Open(pipe, "ls -al",
            UnixPipes.read, Streams.onebuf, errors) THEN
         (* divert all error events related to pipe or Streams.stdout
            to the errors object
         *)
         RelatedEvents.Forward(pipe, errors);
         RelatedEvents.Forward(Streams.stdout, errors);
         IF ~Streams.Copy(pipe, Streams.stdout, -1) THEN
            (* error case: either reading from the pipeline
               or writing to Streams.stdout failed;
               we handle that at the end of this procedure
  *)
         END;
         Streams.Release(pipe);
      END;
      IF RelatedEvents.EventsPending(errors) THEN
         (* print all error events to Streams.stderr and exit *)
         Conclusions.Conclude(errors, Errors.fatal, "");
      END;
   END DoIt;

BEGIN
   DoIt;
END PipeExample2.
--->

PipExample2.od

<---
DEFINITION PipeExample2;
END PipeExample2.
--->

    Source: geocities.com/n0rayr/tips/hacking

               ( geocities.com/n0rayr/tips)                   ( geocities.com/n0rayr)