Module Simula

Class RTS_Outfile

All Implemented Interfaces:
Runnable
Direct Known Subclasses:
RTS_Printfile

public class RTS_Outfile extends RTS_Imagefile
System class Outfile.
  file class outfile;
       begin
          Boolean procedure open(fileimage); text fileimage;
          Boolean procedure close;
          procedure outimage;
          procedure outrecord;
          procedure breakoutimage;
          Boolean procedure checkpoint;
          procedure outchar(c); character c;
          procedure outtext(t); text t;
          text procedure FIELD(w); integer w;
          procedure outint(i,w); integer i,w;
          procedure outfix(r,n,w); long real r; integer n,w;
          procedure outreal(r,n,w); long real r; integer n,w;
          procedure outfrac(i,n,w); integer i,n,w;
 
         ... ;
      end outfile;
 

An object of the class "outfile" is used to represent an image-oriented sequential output file.

Link to GitHub: Source File.

Author:
SIMULA Standards Group, Øystein Myhre Andersen
  • Field Details

    • writer

      protected Writer writer
      The underlying Writer.
  • Constructor Details

    • RTS_Outfile

      public RTS_Outfile(RTS_RTObject SL, RTS_TXT FN)
      Create a new _Outfile.
      Parameters:
      SL - staticLink
      FN - FILENAME
  • Method Details

    • _STM

      public RTS_Outfile _STM()
      Description copied from class: RTS_RTObject
      Method representing the Statements in this Block
      This method is virtual and must be redefined in blocks.
      Overrides:
      _STM in class RTS_Imagefile
      Returns:
      a pointer to this _RTObject
    • open

      public boolean open(RTS_TXT image)
      Procedure open.
       Boolean procedure open(fileimage);  text fileimage;
       if ... then
       begin ... 
          image :- fileimage;
          setpos(1);
          open  := OPEN := true;
       end open;
       

      Procedure "open" establishes the association with an external file (as identified by FILENAME), checks the access modes and causes corresponding opening actions on the external file. If the external file is closed, it is opened.

      Parameters:
      image - the givent image
      Returns:
      true if successful, otherwise false.
    • close

      public boolean close()
      Procedure close.
       Boolean procedure close;
       if OPEN then
       begin ... ! 
          if pos ne 1 then outimage;
          image :- notext;
          ... ; ! perform closing actions on external file;
          OPEN  := false;
          close := true;
       end close;
       

      Procedure "close" causes closing actions on the external file, as specified by the access modes. In addition, the association between the file object and the external file is dissolved. If possible, the external file is closed.

      The procedure "close" calls "outimage" if the position indicator is not equal to 1.

      If successful, "close" returns true. In addition, OPEN is false and "image" references notext.

      Returns:
      true if successful, otherwise false.
    • outimage

      public void outimage()
      Procedure outimage.
       procedure outimage;
                  if not OPEN then error("..." ! file closed; )
                  else begin
                     ... ; ! transfer "image" to external image;
                     image := notext;
                     setpos(1)
                  end outimage;
       

      The transfer of an image from the text "image" to the file is performed by the procedure "outimage". The procedure reacts in an implementation-defined way if the "image" length is not appropriate for the external file. (Depending on file type and host system, the external file does not necessarily record trailing blanks from the "image".)

      This implementation will strip the "image" before output operations.

      After the transfer, "image" is cleared to blanks and the position indicator is set to 1.

      Overrides:
      outimage in class RTS_Imagefile
      Throws:
      RTS_SimulaRuntimeError - if the operation fail
    • writeImage

      protected void writeImage(String ident, String img, boolean blank)
      Output utility: Used by outimage, outrecord and breakoutimage.

      Redefined in PrintFile

      Parameters:
      ident - identifier used in error message
      img - the image to output
      blank - true if the image should be blank-filled after the output operation
    • outrecord

      public void outrecord()
      Procedure outrecord.
       procedure outrecord;
       if not OPEN then  error("..." ! file closed; )
       else begin
              ... ; ! transfer image.sub(1,pos-1);
                    ! Note: no blanking of "image";
              setpos(1)
       end outrecord;
       

      The procedure "outrecord" transfers to the file only that part of "image" which precedes POS. The contents are not blanked after the transfer, although POS is set to one.

      Throws:
      RTS_SimulaRuntimeError - if the operation fail
    • breakoutimage

      public void breakoutimage()
      Procedure breakoutimage.
        procedure breakoutimage;
                  if not OPEN then error("..." ! file closed; )
                  else begin
                     ... ; ! output image.sub(1,pos-1);
                     image := notext;
                     setpos(1)
                  end breakoutimage;
       

      The procedure "breakoutimage" outputs the part of "image" that precedes POS. The output is performed as a partial output of an external image, in the sense that implicit line terminators are suppressed. On some external files this operation is not possible. It then has an effect identical to "outrecord".

      After transfer the "image" is blanked and POS is set to one.

      One use of "breakoutimage" is to allow input from a terminal display on the same line as one on which output (e.g. a prompt) has already been written.

      Throws:
      RTS_SimulaRuntimeError - if the operation fail
    • checkpoint

      public boolean checkpoint()
      Procedure checkpoint.

      All files producing output (sequential output or direct files) contain a Boolean procedure "checkpoint". The procedure causes the environment to attempt to secure the output produced so far. Depending on the nature of the associated external device, this causes completion of output transfer (i.e. intermediate buffer contents are transferred). If this is not possible or meaningful, "checkpoint" is a dummy operation in which case the value false is returned.

      Returns:
      true if successful, otherwise false.