- All Implemented Interfaces:
Runnable
The class "printfile" defines a class for line printer oriented output.
class printfile; begin integer LINE, LINES_PER_PAGE, SPACING, PAGE; integer procedure line; line := LINE; integer procedure page; page := PAGE; Boolean procedure open(fileimage); text fileimage; Boolean procedure close; procedure linesperpage(n); integer n; procedure spacing(n); integer n; procedure eject(n); integer n; procedure outimage; procedure outrecord; SPACING := 1; LINES_PER_PAGE := ... ; ... end printfile;
An object of the class "printfile" is used to represent a line printer oriented output file. The class is a subclass of "outfile". A file image normally represents a line on a printed page.
It is a property of this class that "outfile" attributes, which are redeclared at "printfile" level, are not accessible to the user's program through explicit qualification (qua). Thus these "outfile" procedures ("open", "close", "outimage", "outrecord") may be envisaged as including the following initial code:
procedure X...; inspect this outfile when printfile do X... otherwise ...;
Note: Consequently, possible implicit calls of outimage from outchar, close and the item-oriented output procedures are understood to invoke "printfile.outimage".
The variable LINE indicates the ordinal number of the next line to be printed (on the current page), provided that no implicit or explicit "eject" statement occurs. Its value is accessible through the procedure "line". Note that the value of LINE may be greater than LINES_PER_PAGE (see 10.7.5).
The variable PAGE indicates the ordinal number of the current page. Its value may be retrieved by means of procedure "page".
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 int
The default LINES_PER_PAGE = 66private int
The current LINE(package private) int
The current lines per pageprivate int
The current PAGEprivate int
The current SPACING.Fields inherited from class simula.runtime.RTS_Outfile
writer
Fields 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.void
eject
(int n) Procedure eject.int
line()
Return the current line number.int
linesperpage
(int n) Procedure linesperpage.boolean
Procedure open.int
page()
Return the current page number.void
spacing
(int n) Procedure spacing.protected void
writeImage
(String ident, String img, boolean blank) Output utility: Used by outimage, outrecord and breakoutimage.Methods inherited from class simula.runtime.RTS_Outfile
breakoutimage, checkpoint, outimage, outrecord
Methods inherited from class simula.runtime.RTS_Imagefile
inchar, infrac, inimage, inint, inreal, intext, lastitem, length, more, outchar, outfix, outfrac, 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
-
_DEFAULT_LINES_PER_PAGE
private int _DEFAULT_LINES_PER_PAGEThe default LINES_PER_PAGE = 66 -
_SPACING
private int _SPACINGThe current SPACING. -
_LINE
private int _LINEThe current LINE -
_PAGE
private int _PAGEThe current PAGE -
_LINES_PER_PAGE
int _LINES_PER_PAGEThe current lines per page
-
-
Constructor Details
-
RTS_Printfile
Create a new _Printfile- 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.- Overrides:
_STM
in classRTS_Outfile
- Returns:
- a pointer to this _RTObject
-
line
public int line()Return the current line number.- Returns:
- the current line number
-
page
public int page()Return the current page number.- Returns:
- the current page number
-
open
Procedure open.Boolean procedure open(fileimage); text fileimage; if ... then begin ... image :- fileimage; PAGE := 0; LINE := 1; setpos(1); eject(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. *
- Overrides:
open
in classRTS_Outfile
- 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; eject(LINES_PER_PAGE); PAGE := ... ; LINE := 0; SPACING := 1; LINES_PER_PAGE:= ... ; 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, PAGE, LINE, SPACING, LINES_PER_PAGE, OPEN and "image" are reinitiated.
- Overrides:
close
in classRTS_Outfile
- Returns:
- true if successful, otherwise false.
-
linesperpage
public int linesperpage(int n) Procedure linesperpage.integer procedure linesperpage(n); integer n; begin linesperpage := LINES_PER_PAGE; LINES_PER_PAGE:= if n > 0 then n else if n < 0 then maxint else ... ; ! default value;
The variable LINES_PER_PAGE indicates the maximum number of physical lines that may be printed on each page, including intervening blank lines. An implementation-defined value is assigned to the variable at the time of object generation, and when the printfile is closed. The value of the variable may be retreived by a call on "linesperpage"; in addition the variable is givan a new value as follows.
If the parameter to "linesperpage" is zero, LINES_PER_PAGE is reset to the original value (assigned at object generation). A parameter value less than zero may be used to indicate an "infinite" value of LINES_PER_PAGE, thus avoiding any automatic calls on "eject".
- Parameters:
n
- the requested lines per page- Returns:
- the new lines per page
-
spacing
public void spacing(int n) Procedure spacing.procedure spacing(n); integer n; if 0<=n and n<=LINES_PER_PAGE then SPACING := n else error("..." ! Parameter out of range; );
The variable SPACING represents the value by which the variable LINE is incremented after the next printing operation. Its value may be changed by the procedure "spacing". A call on the procedure "spacing" with a parameter less than zero or greater than LINES_PER_PAGE constitutes an error. The effect of a a parameter to "spacing" which is equal to zero may be defined as forcing successive printing operations on the same physical line. Note, however, that on some physical media this may not be possible, in which case spacing(0) has the same effect as spacing(1) (i.e. no overprinting).
- Parameters:
n
- line increment- Throws:
RTS_SimulaRuntimeError
- if n is out of range
-
eject
public void eject(int n) Procedure eject.procedure eject(n); integer n; if not OPEN then error("..." ! file closed;) else if n <= 0 then error("..." ! Parameter out of range;) else begin if n > LINES_PER_PAGE then n := 1; if n <= LINE then begin ... ; ! change to new page on external file; PAGE := PAGE + 1 end; ... ; ! move to line "n" on current (external) page; LINE := n end eject;
The procedure "eject" is used to position to a certain line identified by the parameter, n. The variable "PAGE" is incremented by one each time an explicit or implicit "eject" implies a new page.
The following cases can be distinguished:
n <= 0 : error n > LINES_PER_PAGE : Equivalent to eject (1) n <= LINE : Position to line number n on the next page n > LINE : Position to line number n on the current page
The tests above are performed in the given sequence.- Parameters:
n
- requested line number- Throws:
RTS_SimulaRuntimeError
- if the operation fail
-
writeImage
Description copied from class:RTS_Outfile
Output utility: Used by outimage, outrecord and breakoutimage.Redefined in PrintFile
- Overrides:
writeImage
in classRTS_Outfile
- Parameters:
ident
- identifier used in error messageimg
- the image to outputblank
- true if the image should be blank-filled after the output operation
-