- All Implemented Interfaces:
Runnable
imagefile class infile; begin Boolean ENDFILE; Boolean procedure endfile; endfile:= ENDFILE; Boolean procedure open(fileimage); text fileimage; Boolean procedure close; procedure inimage; Boolean procedure inrecord; character procedure inchar; Boolean procedure lastitem; text procedure intext(w); integer w; integer procedure inint; long real procedure inreal; integer procedure infrac; ENDFILE:= true ... end infile;
An object of the class "infile" is used to represent an image-oriented sequential input file.
The variable ENDFILE is true whenever the file object is closed or the external file is exhausted (i.e. "end of file" has been encountered). The procedure "endfile" gives access to the value of ENDFILE.
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 TypeFieldDescriptionprivate BufferedReader
The BufferedReader used.private String
Utility variableFields inherited from class simula.runtime.RTS_Imagefile
_ENDFILE, image
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 TypeMethodDescription_STM()
Method representing the Statements in this Block
This method is virtual and must be redefined in blocks.boolean
close()
Procedure close.boolean
endfile()
Procedure endfile.void
inimage()
Procedure Inimage.boolean
inrecord()
Procedure inrecord.boolean
Procedure open.Methods inherited from class simula.runtime.RTS_Imagefile
inchar, infrac, inint, inreal, intext, lastitem, length, more, outchar, outfix, outfrac, outimage, outint, outreal, outreal, outtext, outtext, pos, setpos
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
-
lineReader
The BufferedReader used. -
rest
Utility variable
-
-
Constructor Details
-
RTS_Infile
Create a new _Infile.- Parameters:
SL
- staticLinkFN
- FILENAME
-
-
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.- Overrides:
_STM
in classRTS_Imagefile
- Returns:
- a pointer to this _RTObject
-
open
Procedure open.
Boolean procedure open(fileimage); text fileimage; if ... then begin ... ! see 10.1.2; ENDFILE := false; image :- fileimage; image := notext; setpos(length+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.
If successful, "open" returns true and sets ENDFILE false. In addition, "image" references the parameter "fileimage" which is space-filled.
- Parameters:
image
- the givent image- Returns:
- true if successful, otherwise false.
-
close
public boolean close()Procedure close.Boolean procedure close; if OPEN then begin ... ; ! perform closing actions ...; image :- notext; OPEN := false; close := ENDFILE := 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.
If successful, "close" returns true. In addition, OPEN is false, ENDFILE is true and "image" references notext.
- Returns:
- true if successful, otherwise false.
-
endfile
public boolean endfile()Procedure endfile.Returns true whenever the file object is closed or the external file is exhausted (i.e. "end of file" has been encountered).
- Returns:
- the resulting boolean value
-
inimage
public void inimage()Procedure Inimage.procedure inimage; if ENDFILE then error("...") else begin ... ; ! attempt to transfer external image to "image"; if ... ! "image" too short; then error("...") else if ... ! there was no more to read; then begin ENDFILE := true; image :- "!25!" end else ... ; ! pad "image" with space(s); setpos(1) end inimage;
The procedure "inimage" performs the transfer of an external file image into "image". A run-time error occurs if "image" is notext or too short to contain the external image. If it is longer than the external image, the latter is left-adjusted within "image" and the remainder of the text is filled with spaces. The position indicator is set to one.
Note: If an "end of file" is encountered, EM ('!25!') is generated as a single character external image, and the variable ENDFILE is given the value true. A call on "inimage" or "inrecord" when ENDFILE already has the value true constitutes a run-time error.
- Overrides:
inimage
in classRTS_Imagefile
- Throws:
RTS_SimulaRuntimeError
- if inimage fail
-
inrecord
public boolean inrecord()Procedure inrecord.Boolean procedure inrecord; if not OPEN or ENDFILE then error("...") else begin ... ; ! transfer external image to "image" (no space-filling); if ... ! no more to read; then begin ENDFILE := true; setpos(1); image.putchar('!25!') end Note - POS = 2 now else begin setpos(... !number of characters transferred + 1; ); inrecord:= not ...! whole external image received?; end if end inrecord;
The procedure "inrecord" is similar to "inimage" with the following exceptions. Whenever the number of characters accessible in the external image is less than "length", the rest of "image" is left unchanged. The part of the "image" that was changed is from pos 1 upto (but not including) the resulting value of POS. Moreover, if the external image is too long, only the "length" first characters are input. The value returned by the procedure is true and the remaining characters may be input through subsequent "inrecord" (or possibly "inimage") statements. Otherwise, if the input of the external image was completed, the value false is returned.
Note: If an "end of file" is encountered, EM ('!25!') is generated as a single character external image, and the variable ENDFILE is given the value true. A call on "inimage" or "inrecord" when ENDFILE already has the value true constitutes a run-time error.
- Returns:
- true if a partial record is read, otherwise false
- Throws:
RTS_SimulaRuntimeError
- if inrecord fail
-