- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
RTS_Directfile
,RTS_Infile
,RTS_Outfile
The (file) class "imagefile" defines the common attributes for all image- oriented files.
file class imagefile; begin text image; procedure setpos(i); integer i; image.setpos(i); integer procedure pos; pos := image.pos; Boolean procedure more; more := image.more; integer procedure length; length := image.length; end imagefile;
The individual logical unit of an external file associated with an imagefile is called an "external image". Each external image is an an ordered sequence of characters.
The variable "image" is used to reference a text frame which acts as a buffer, in the sense that it contains the external image currently being processed.
The procedures "setpos", "pos", "more" and "length" are introduced for reasons of convenience.
The three standard subclasses of imagefile are "infile" (sequential input file), "outfile" (sequential output file) and "directfile" (bidirectional direct file). In addition, "printfile", a standard subclass of class outfile, is available. It represents a line printer oriented file.
Link to GitHub: Source File.
- Author:
- SIMULA Standards Group, Øystein Myhre Andersen
-
Nested Class Summary
Nested classes/interfaces inherited from class simula.runtime.RTS_File
RTS_File._CreateAction
Nested classes/interfaces inherited from class simula.runtime.RTS_RTObject
RTS_RTObject.ForElt, RTS_RTObject.ForList, RTS_RTObject.ForListIterator, RTS_RTObject.OperationalState, RTS_RTObject.RTS_BOOLEAN_ARRAY, RTS_RTObject.RTS_BOUNDS, RTS_RTObject.RTS_CHARACTER_ARRAY, RTS_RTObject.RTS_INTEGER_ARRAY, RTS_RTObject.RTS_LABEL, RTS_RTObject.RTS_LONG_REAL_ARRAY, RTS_RTObject.RTS_NAME<T>, RTS_RTObject.RTS_REAL_ARRAY, RTS_RTObject.RTS_REALTYPE_ARRAY, RTS_RTObject.RTS_REF_ARRAY<T>, RTS_RTObject.RTS_TEXT_ARRAY, RTS_RTObject.SingleElt<T>, RTS_RTObject.SingleTValElt, RTS_RTObject.StepUntil, RTS_RTObject.UncaughtExceptionHandler, RTS_RTObject.WhileElt<T>, RTS_RTObject.WhileTValElt
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
The variable ENDFILE.The image attribute of this _Imagefile.Fields inherited from class simula.runtime.RTS_File
_APPEND, _ASK_PAPER, _BOT_MARGIN, _CANREAD, _CANWRITE, _CHARSET, _CREATE, _DEFAULT_BYTESIZE, _FONT, _LEFT_MARGIN, _OPEN, _ORIENTATION, _PURGE, _RIGHT_MARGIN, _SYNCHRONOUS, _TOP_MARGIN, FILE_NAME
Fields inherited from class simula.runtime.RTS_ENVIRONMENT
_STARTTIME, CURRENTDECIMALMARK, CURRENTLOWTEN, EXCEPTION_HANDLER, maxint, maxlongreal, maxreal, minint, minlongreal, minreal, simulaReleaseID
Fields inherited from class simula.runtime.RTS_RTObject
_CORUT, _CTX, _CUR, _DL, _INPUT_LINELENGTH, _JTX, _OUTPUT_LINELENGTH, _SL, _STATE, _SYSIN, _SYSOUT, NOTEXT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate RTS_TXT
_FIELD
(int w) Utility procedure _FIELD._STM()
Method representing the Statements in this Block
This method is virtual and must be redefined in blocks.private RTS_TXT
Starting at pos return the rest of image.char
inchar()
Procedure inchar.int
infrac()
Procedure infrac.void
inimage()
Procedure inimage.int
inint()
Procedure inint.double
inreal()
Procedure inreal.intext
(int w) Procedure intext.boolean
lastitem()
Procedure lastintem.int
length()
Returns the image's length.boolean
more()
Returns the image's more.void
outchar
(char c) Procedure outchar.void
outfix
(double r, int n, int w) Procedure outfix.void
outfrac
(int i, int n, int w) Procedure outfrac.void
outimage()
Procedure outimage.void
outint
(int i, int w) Procedure outint.void
outreal
(double r, int n, int w) Procedure outreal.void
outreal
(float r, int n, int w) Procedure outreal.void
Procedure outtext.void
Procedure outtext.int
pos()
Returns the image's pos.void
setpos
(int p) Set pos indikator in image.Methods inherited from class simula.runtime.RTS_File
doCreateAction, doPurgeAction, filename, isopen, setaccess, setCharset, setFont, setMargins, TRACE_OPEN, trySelectFile
Methods inherited from class simula.runtime.RTS_BASICIO
toString
Methods inherited from class simula.runtime.RTS_ENVIRONMENT
_char, _IPOW, _IS, abs, abs, abs, addepsilon, addepsilon, arccos, arcsin, arctan, arctan2, Char, clocktime, cos, cosh, cotan, cputime, datetime, decimalmark, DEFEXCEPTION, digit, discrete, draw, edfix, edit, edit, edit, edit, edit, edtime, entier, Erlang, error, exp, getIntInfo, getTextInfo, giveIntInfo, giveTextInfo, hash, histd, histo, isochar, isorank, letter, linear, ln, loadChar, log10, lowcase, lowerbound, lowten, max, max, max, max, max, min, min, min, min, min, mod, negexp, normal, Poisson, printStaticChain, printThreadList, randint, rank, rem, rts_utility, sign, simulaid, sin, sinh, sqrt, storeChar, subepsilon, subepsilon, tan, tanh, uniform, upcase, upperbound, waitSomeTime
Methods inherited from class simula.runtime.RTS_RTObject
_ASGSTR, _ASGTXT, _GOTO, _JUMPTABLE, _JUMPTABLE, _LABEL, _PRE_LABEL, _PRE_TABLE, _SIM_LABEL, _TXTREL_EQ, _TXTREL_GE, _TXTREL_GT, _TXTREL_LE, _TXTREL_LT, _TXTREL_NE, _VALUE, arrayValue, BBLK, blanks, BPRG, call, call, CONC, copy, detach, detach, detach, doubleValue, EBLK, edObjectAttributes, edObjectIdent, floatValue, getErrorMessage, intValue, isDetachUsed, isQPSystemBlock, objectTraceIdentifier, objectTraceIdentifier, objectValue, procValue, resume, resume, resume, swapCoroutines, sysin, sysout, terminate_program, TRACE_GOTO, TRF_EQ, TRF_NE
-
Field Details
-
image
The image attribute of this _Imagefile. -
_ENDFILE
protected boolean _ENDFILEThe variable ENDFILE. It is true when the file is closed or when an image with location greater than "lastloc" has been input (through "inimage"). It is set after each "inimage" statement. The procedure "endfile" returns the current value.
-
-
Constructor Details
-
RTS_Imagefile
Create a new _Imagefile.- Parameters:
SL
- staticLinkFN
- file name
-
-
Method Details
-
_STM
Description copied from class:RTS_RTObject
Method representing the Statements in this Block
This method is virtual and must be redefined in blocks. -
setpos
public void setpos(int p) Set pos indikator in image.- Parameters:
p
- new pos in image
-
pos
public int pos()Returns the image's pos.- Returns:
- the image's pos
-
more
public boolean more()Returns the image's more.- Returns:
- the image's more
-
length
public int length()Returns the image's length.- Returns:
- the image's length
-
outimage
public void outimage()Procedure outimage.This method is virtual and may be redefined in subclasses.
- Throws:
RTS_SimulaRuntimeError
- if no redefinition is available
-
outchar
public void outchar(char c) Procedure outchar.procedure outchar(c); character c; begin if not more then outimage; image.putchar(c) end outchar;
The procedure "outchar" stores a character in the POS position of "image". If "more" is false, "outimage" is called first.
- Parameters:
c
- the character to output
-
_FIELD
Utility procedure _FIELD.text procedure FIELD(w); integer w; if w>length then error("..." ! Item too long; ) else begin if pos+w-1 > length then outimage; FIELD :- image.sub(pos,w); setpos(pos+w) end FIELD;
Seeoutint(int,int)
- Parameters:
w
- the width of the field.- Returns:
- the resulting text field
- Throws:
RTS_SimulaRuntimeError
- if Item is too long
-
outint
public void outint(int i, int w) Procedure outint.The procedures "outint", "outfix", "outreal" and "outfrac" are defined in terms of the corresponding editing procedures of "image". They provide facilities for "item-oriented" output. Each item is edited into a "field" (subtext of "image") normally starting at the current accessible character. POS is advanced correspondingly. If the remainder of "image" is too short to contain the item, "outimage" is called implicitly prior to the editing operation. The field is space-filled before the editing operation.
A run-time error occurs if a field cannot be contained within the full length of "image".
Parameter "w" determines both the length of this field and the adjustment of the item within it, as follows.
w > 0 The field length is w, the item is right-adjusted. w < 0 The field length is abs(w), the item is left-adjusted. w = 0 The field length is the exact number of characters needed to contain the item (i.e. no leading or trailing spaces). procedure outint(i,w); integer i,w; if w = 0 then FIELD(...).putint(i) ! see below; else if w < 0 then begin text f; f :- FIELD(-w); f := notext; f.sub(1,...).putint(i) end else FIELD(w).putint(i);
- Parameters:
i
- the integer value to be edited and outputedw
- the width of editing field- Throws:
RTS_SimulaRuntimeError
- if the Item is too long in output operation
-
outfix
public void outfix(double r, int n, int w) Procedure outfix.See
outint(int,int)
- Parameters:
r
- the long real value to be edited and outputedn
- the number of digits after decimal signw
- the width of editing field- Throws:
RTS_SimulaRuntimeError
- if the Item is too long in output operation
-
outreal
public void outreal(double r, int n, int w) Procedure outreal.See
outint(int,int)
- Parameters:
r
- the long real value to be edited and outputedn
- the number of digits after decimal signw
- the width of editing field- Throws:
RTS_SimulaRuntimeError
- if the Item is too long in output operation
-
outreal
public void outreal(float r, int n, int w) Procedure outreal.See
outint(int,int)
- Parameters:
r
- the real value to be edited and outputedn
- the number of digits after decimal signw
- the width of editing field- Throws:
RTS_SimulaRuntimeError
- if the Item is too long in output operation
-
outfrac
public void outfrac(int i, int n, int w) Procedure outfrac.See
outint(int,int)
- Parameters:
i
- the integer value to be edited and outputedn
- the number of digits after decimal signw
- the width of editing field- Throws:
RTS_SimulaRuntimeError
- if the Item is too long in output operation
-
outtext
Procedure outtext.procedure outtext(t); text t; begin if pos>1 and then t.length>length-pos+1 then outimage; t.setpos(1); while t.more do outchar(t.getchar); end outtext;
- Parameters:
s
- the String representation of the text
-
outtext
Procedure outtext.See
outtext(String)
- Parameters:
t
- the _TXT representation of the text
-
inimage
public void inimage()Procedure inimage.This method is virtual and may be redefined in subclasses.
- Throws:
RTS_SimulaRuntimeError
- if no redefinition is available
-
inchar
public char inchar()Procedure inchar.character procedure inchar; begin if not more then inimage; inchar:= image.getchar end inchar;
The procedure "inchar" gives access to and scans past the next character. Note: The result may be the "EOF-character" EM (ISOrank 25).
- Returns:
- the resulting character
-
intext
Procedure intext.text procedure intext(w); integer w; begin text t; intext :- t :- blanks(w); while t.more do t.putchar(inchar) end intext;
The expression "intext(w)" where "w" is a positive integer is a reference to a new alterable main frame of length w containing a copy of the next w characters of the file. POS is set to the following character. The expression "intext(0)" references notext. In contrast to the item-oriented procedures (see below), "intext" operates on a continuous stream of characters, reading several images if necessary.
Note: The result may be a reference to an "EOF-image" (cf. inimage/inrecord).
- Parameters:
w
- the width of the input field.- Returns:
- the resulting text
-
lastitem
public boolean lastitem()Procedure lastintem.Boolean procedure lastitem; begin character c; c := ' '; while not ENDFILE and then (c=' ' or else c='!9!') do c := inchar; lastitem := ENDFILE; if c ne ' ' then setpos(pos-1) end lastitem;
The purpose of the procedure "lastitem" is to skip past all SP and HT characters (ISOrank 32 and 9 respectively). The process of scanning may involve the transfer of several successive external images. If the file contains no further non-space, non-tab characters the value true is returned.
- Returns:
- the resulting boolean value
-
ImageRest
Starting at pos return the rest of image.- Returns:
- the rest of image
-
inint
public int inint()Procedure inint.integer procedure inint; if lastitem then error("..." ! Inint: End of file ;) else begin text t; t:- image.sub(pos,length-pos+1); inint := t.getint; setpos(pos+t.pos-1) end inint;
The procedures "inint" is defined in terms of the corresponding de-editing procedure of "image". This procedure, starting at the current "pos", skip spaces and tab's, and then scan past and convert a numeric item.
- Returns:
- the value of an integer item.
-
inreal
public double inreal()Procedure inreal.long real procedure inreal; if lastitem then error("..." ! Inreal: End of file; ) else begin text t; t :- image.sub(pos,length-pos+1); inreal := t.getreal; setpos(pos+t.pos-1) end inreal;
The procedure "inreal" is defined in terms of the corresponding de-editing procedure of "image". This procedure, starting at the current "pos", skip spaces and tab's, and then scan past and convert a numeric item.
- Returns:
- the value of an real item.
-
infrac
public int infrac()Procedure infrac.integer procedure infrac; if lastitem then error("..." ! Infrac: End of file; ) else begin text t; t :- image.sub(pos,length-pos+1); infrac := t.getfrac; setpos(pos+t.pos-1) end infrac;
The procedure "infrac" is defined in terms of the corresponding de-editing procedure of "image". This procedure, starting at the current "pos", skip spaces and tab's, and then scan past and convert a numeric item.
- Returns:
- the value of a fractionated integer item.
-