Class RTS_Inbytefile

All Implemented Interfaces:
Runnable

public class RTS_Inbytefile extends RTS_Bytefile

System class Inbytefile.

 bytefile class inbytefile; begin
     Boolean ENDFILE;
     Boolean procedure endfile;  endfile:= ENDFILE;
     Boolean procedure open;
     Boolean procedure close; 
     short integer procedure inbyte; 
     text procedure intext(t);   text t;

     ENDFILE:= true;
     ...
end inbytefile;

An object of the class "inbytefile" is used to represent a byte-oriented sequential input file.

Variable "ENDFILE" is true if there are no more bytes to read. The procedure "endfile" returns the value of ENDFILE.

Link to GitHub: Source File.

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

    • inputStream

      private InputStream inputStream
      The InputStream used.
    • _ENDFILE

      protected boolean _ENDFILE
      The variable ENDFILE.
  • Constructor Details

    • RTS_Inbytefile

      public RTS_Inbytefile(RTS_RTObject SL, RTS_TXT FN)
      Create a new _Inbytefile.
      Parameters:
      SL - staticLink
      FN - file name
  • Method Details

    • _STM

      public RTS_Inbytefile _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_Bytefile
      Returns:
      a pointer to this _RTObject
    • endfile

      public boolean endfile()

      Procedure endfile.

      Boolean procedure endfile;  endfile:= ENDFILE;
      
      Returns:
      true if there are no more bytes to read.
    • open

      public boolean open()

      Procedure open.

      Boolean procedure open;
         if ... then begin ...  
            ENDFILE  := false;
            BYTESIZE := ... ! value of access mode BYTESIZE;
            open     := OPEN := true;
      end open;
      
      Returns:
      true if the file was successfully opened, otherwise false
    • close

      public boolean close()

      Procedure close.

      Boolean procedure close;
         if OPEN then begin ... ! see 10.1.2;
            ... ;
            OPEN  := false;
            close := ENDFILE := true;
      end close;
      
      Returns:
      false if the file is not open.
    • inbyte

      public int inbyte()

      Procedure inbyte.

      short integer procedure inbyte;
         if ENDFILE then error("..." ! End of file ;)
         else if ... ! no more bytes to read;
         then ENDFILE := true  ! inbyte returns zero;
         else inbyte  := ...! next byte of size BYTESIZE;
      

      The procedure "inbyte" returns the short integer value corresponding to the input byte. If there are no more bytes to read, a zero result is returned. If prior to an "inbyte" call ENDFILE is true, a run-time error occurs.

      Returns:
      the resulting integer value
      Throws:
      RTS_SimulaRuntimeError - if inbyte fail
    • in2byte

      public int in2byte()
      Procedure in2byte.
      Returns:
      the resulting integer value
      Throws:
      RTS_SimulaRuntimeError - if intext fail
    • intext

      public RTS_TXT intext(RTS_TXT t)

      Procedure intext.

      text procedure intext(t);   text t;
      begin
            t.setpos(1);
            while t.more and not ENDFILE do t.putchar(char(inbyte));
            if ENDFILE then t.setpos(t.pos-1);
            intext:- t.sub(1,t.pos-1)
      end intext;
      

      The procedure "intext" fills the frame of the parameter "t" with successive input bytes.

      Parameters:
      t - the text frame to fill
      Returns:
      the text frame