- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
RTS_Bytefile
,RTS_Imagefile
class file(FILENAME); value FILENAME; text FILENAME; begin Boolean OPEN; text procedure filename; filename :- copy(FILENAME); Boolean procedure isopen; isopen := OPEN; Boolean procedure setaccess(mode); text mode; ... 10.1.1; if FILENAME = notext then error("..."); end file;
"File" is the common prefix class for all input/output classes.
A file is either open or inaccessible as indicated by the variable "OPEN". The procedure "isopen" returns the current value of "OPEN". A file is initially inaccessible (e.g. closed).
Each file object has a text attribute FILENAME. This text value must at "open" identify an external file which, through an implementation-defined mechanism, becomes associated with the file object. If the parameter value is notext, a run-time error occurs.
The procedure "filename" retrieves the value of FILENAME.
Link to GitHub: Source File.
- Author:
- SIMULA Standards Group, Øystein Myhre Andersen
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static enum
CREATE: Action is performed at 'open'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 output to the file is added to the existing contents of the file.protected boolean
Indicator to decide whether to ask, by a dialog, for the paper and orientation.protected double
The papar's current bottom marginprotected boolean
If the value is true, input operations can be performed.protected boolean
If the value is true, output operations can be performed.protected Charset
The current character set when encode/decode files.protected RTS_File._CreateAction
CREATE: Action is performed as 'open'protected final int
The default BYTESIXE is 8 in this implementation.protected Font
The current Font.protected double
The papar's current left marginprotected boolean
The OPEN indicator.protected int
The current paper orientation.protected boolean
PURGE: Action is performed at 'close'protected double
The papar's current right marginprotected boolean
The access mode SYNCHRONOUS.protected double
The papar's current top marginprotected final RTS_TXT
The 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.protected File
Do the Create action.protected void
Do the Purge actionfilename()
Returns the filename.boolean
isopen()
Returns true when this file is open.boolean
External file access control.protected boolean
setCharset
(String id) Set new Charset.protected boolean
Set new Font.protected boolean
setMargins
(String id) Utility: Set paper margins.protected void
TRACE_OPEN
(String mss) Utility: Trace file open.protected File
trySelectFile
(String fileName) Try to select a file named 'fileName'.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
-
FILE_NAME
The file name. -
_OPEN
protected boolean _OPENThe OPEN indicator. -
_CREATE
CREATE: Action is performed as 'open' -
_PURGE
protected boolean _PURGEPURGE: Action is performed at 'close'The value "purge" implies that the external file may be deleted by the environment when it is closed (in the sense that it becomes inaccessible to further program access). The value "nopurge" implies no such deletion.
-
_CANREAD
protected boolean _CANREADIf the value is true, input operations can be performed.This mode is relevant only for direct files.
-
_CANWRITE
protected boolean _CANWRITEIf the value is true, output operations can be performed.This mode is relevant only for direct files.
-
_APPEND
protected boolean _APPENDThe output to the file is added to the existing contents of the file.If the value is true, output to the file is added to the existing contents of the file. The value false implies for a sequential file that, after "close", the external file will contain only the output produced while the file was open.
The mode is not relevant for in(byte)files.
-
_CHARSET
The current character set when encode/decode files. -
_DEFAULT_BYTESIZE
protected final int _DEFAULT_BYTESIZEThe default BYTESIXE is 8 in this implementation.- See Also:
-
_SYNCHRONOUS
protected boolean _SYNCHRONOUSThe access mode SYNCHRONOUS.It is available for Out- files and Direct- files. For Outfile/OutBytefile, each write operation will be followed by a flush to ensure that the underlying storage device is updated. For Directfile/DirectBytefile the underlaying Java RandomAccessFile will be created open for reading and writing, and also require that every update to the file's content or metadata be written synchronously to the underlying storage device.
-
_FONT
The current Font. -
_ORIENTATION
protected int _ORIENTATIONThe current paper orientation. -
_ASK_PAPER
protected boolean _ASK_PAPERIndicator to decide whether to ask, by a dialog, for the paper and orientation. -
_LEFT_MARGIN
protected double _LEFT_MARGINThe papar's current left margin -
_RIGHT_MARGIN
protected double _RIGHT_MARGINThe papar's current right margin -
_TOP_MARGIN
protected double _TOP_MARGINThe papar's current top margin -
_BOT_MARGIN
protected double _BOT_MARGINThe papar's current bottom margin
-
-
Constructor Details
-
RTS_File
Create a new _File.- 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_RTObject
- Returns:
- a pointer to this _RTObject
-
filename
Returns the filename.- Returns:
- the filename
-
isopen
public boolean isopen()Returns true when this file is open.- Returns:
- true when this file is open
-
trySelectFile
Try to select a file named 'fileName'.If no file exists with that fileName it will try several possibilities:
- First it will search the Option.RUNTIME_USER_DIR
- Second, system properties "user.dir" and "java.class.path".parent
- Finally, a JFileChooser dialog is opened to let the user select the file
- Parameters:
fileName
- the given fale name- Returns:
- the resulting file or null
-
setaccess
External file access control.Certain attributes (not specified in the file outline) control the access to the external file. The values of these attributes are set when the file object is opened or closed, from a set of default values possibly modified by successive calls to the procedure "setaccess".
The standard attribute modes are SHARED, APPEND, CREATE, READWRITE, BYTESIZE, REWIND and PURGE.
The parameter "mode" to procedure "setaccess" contains one of the standard values as given above, namely "shared", "noshared", "append", "noappend", "create", "nocreate", "anycreate", "readonly", "writeonly", "readwrite", "bytesize:X" (where X is a positive integer), "rewind", "norewind", "purge" and "nopurge".
It is recommended that implementation-defined parameter values have the percent character % as the first character of the text.
Unrecognized modes are ignored and "setaccess" then returns the value false. The value is true otherwise.
See Simula Standard Chapter 10, INPUT-OUTPUT.
- Parameters:
mode
- the access mode text- Returns:
- true if mode is recognized, otherwise false.
-
setCharset
Set new Charset.- Parameters:
id
- charset identifier- Returns:
- true if the operation was successful, otherwise false
-
setFont
Set new Font.- Parameters:
id
- font identifier- Returns:
- true if the operation was successful, otherwise false
-
setMargins
Utility: Set paper margins.- Parameters:
id
- an margin string "top:left:bottom:right"- Returns:
- true if the operation was successful, otherwise false
-
doCreateAction
Do the Create action.- Returns:
- the File
-
doPurgeAction
protected void doPurgeAction()Do the Purge action -
TRACE_OPEN
Utility: Trace file open.- Parameters:
mss
- a trace message
-