The type text serves to declare or specify a text variable quantity.
A text value is a string, i.e. an ordered sequence (possibly empty) of characters. The number of characters is called the "length" of the text value.
A text frame is a memory device which contains a nonempty text value. A text frame has a fixed length and can only contain text values of this length. A text frame may be "alterable" or "constant". A constant frame always contains the same text value. An alterable text frame may have its contents modified. The maximum length of a text frame is implementation-defined.
A text reference identifies a text frame. The reference is said to possess a value, which is the contents of the identified frame. The special text reference notext identifies "no frame". The value of notext is the empty text value.
A text variable is conceptually an instance of a composite structure
ref(TEXTOBJ) OBJ; integer START, LENGTH, POS;
It references (and has as its value the contents of) some text frame defined by the three first components. POS identifies the current character. See 3.1.2.
Link to GitHub: Source File.
- Author:
- SIMULA Standards Group, Øystein Myhre Andersen
-
Field Summary
Modifier and TypeFieldDescription(package private) int
The length of this text.(package private) RTS_TEXTOBJ
The Text object referred.(package private) int
Current index of OBJ.MAIN[], counting from zero.(package private) int
Start index of OBJ.MAIN[], counting from zero.private static final int
Unicode minus sign = 8722 = 0x2212 -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate static String
Real Edit Utility: Add plus exponent to the given stringprivate static void
Check if it is legal to assign to the given text reference.static boolean
Procedure constant.(package private) String
Utility: Edit stripped text into a String.(package private) String
edText()
Utility: Edit text into a String.(package private) String
Utility: Edit text until current pos into a String.static char
Procedure getchar.static int
Procedure getfrac.private static String
Scan the input text for a fraction item.static int
Procedure getint.private static String
Scan the input text for an integer item.static double
Procedure getreal.private static String
Scan the input text for a real item.static int
Procedure length.static RTS_TXT
Procedure main.static boolean
Procedure more.static int
Procedure pos.static void
Procedure putchar.static void
Procedure putfix.static void
Procedure putfrac.static void
Procedure putint.static void
Procedure putreal.static void
Procedure putreal.private static void
putRealResult
(RTS_TXT T, String output) Put the result of putReal type operation into the text T.private static void
Put the result of put... operation into the text T.static void
Procedure setpos.static int
Procedure start.static RTS_TXT
Procedure strip.static RTS_TXT
Procedure sub.toString()
-
Field Details
-
UNICODE_MINUS_SIGN
private static final int UNICODE_MINUS_SIGNUnicode minus sign = 8722 = 0x2212- See Also:
-
OBJ
RTS_TEXTOBJ OBJThe Text object referred. -
START
int STARTStart index of OBJ.MAIN[], counting from zero.Note this differ from Simula Definition.
-
LENGTH
int LENGTHThe length of this text. -
POS
int POSCurrent index of OBJ.MAIN[], counting from zero.Note this differ from Simula Definition.
-
-
Constructor Details
-
RTS_TXT
public RTS_TXT()Create a new _TXT. -
RTS_TXT
Create a new _TXT containing the string s.- Parameters:
s
- initial string value
-
-
Method Details
-
toString
-
edText
String edText()Utility: Edit text into a String.- Returns:
- the resulting String
-
edStripedText
String edStripedText()Utility: Edit stripped text into a String.- Returns:
- the resulting String
-
edTextToPos
String edTextToPos()Utility: Edit text until current pos into a String.- Returns:
- the resulting String
-
constant
Procedure constant.- Parameters:
T
- the argument text reference- Returns:
- true if T is constant, otherwise false
-
start
Procedure start.- Parameters:
T
- the argument text reference- Returns:
- the start position of T within T'main frame
-
length
Procedure length.- Parameters:
T
- the argument text reference- Returns:
- the length of T
-
main
Procedure main."X.main" is a reference to the main frame which contains the frame referenced by X.
The following relations are true for any text variable X:
X.main.length >= X.length X.main.main == X.main
In addition,notext.main == notext "ABC".main = "ABC" (but "ABC".main =/= "ABC")
- Parameters:
T
- the argument text reference- Returns:
- the main frame of T
-
pos
Procedure pos.integer procedure pos; pos := POS;
- Parameters:
T
- the argument text reference- Returns:
- the current POS
-
setpos
Procedure setpos.procedure setpos(i); integer i; POS := if i < 1 or i > LENGTH + 1 then LENGTH + 1 else i;
- Parameters:
T
- the argument text referencep
- the new POS
-
more
Procedure more.- Parameters:
T
- the argument text reference- Returns:
- true if T.pos < T.length, otherwise false
-
getchar
Procedure getchar.Get the character at the current POS of T. POS is then incremented.
- Parameters:
T
- the argument text reference- Returns:
- the character at the current pos
- Throws:
RTS_SimulaRuntimeError
- if the operation fail
-
checkAssignable
Check if it is legal to assign to the given text reference.- Parameters:
T
- the given text reference- Throws:
RTS_SimulaRuntimeError
- if assignment is illegal
-
putchar
Procedure putchar.Put the character c into the text T at the current POS. POS is then incremented.
- Parameters:
T
- the argument text referencec
- the argument character- Throws:
RTS_SimulaRuntimeError
- if the operation fail
-
sub
Procedure sub.If legal, "X.sub(i,n)" references that subframe of X whose first character is character number i of X, and which contains n consecutive characters. The POS attribute of the expression defines a local numbering of the characters within the subframe. If n = 0, the expression references notext.
If legal, the following Boolean expressions are true for any text variable X:
X.sub(i,n).sub(j,m) == X.sub(i+j-1,m) n ne 0 imp X.main == X.sub(i,n).main X.main.sub(X.start,X.length) == X
- Parameters:
T
- the argument text referencei
- first character indexn
- number of charaters- Returns:
- the resulting text reference
- Throws:
RTS_SimulaRuntimeError
- if the operation fail
-
strip
Procedure strip.The expression "X.strip" is equivalent to "X.sub(1,n)", where n indicates the position of the last non-blank character in X. If X does not contain any non-blank character, notext is returned.
Let X and Y be text variables. Then after the value assignment "X:=Y", if legal, the relation "X.strip = Y.strip" has the value true, while "X = Y" is true only if X.length = Y.length.
- Parameters:
T
- the argument text reference- Returns:
- the resulting text reference
-
getIntegerItem
Scan the input text for an integer item.INTEGER-ITEM = SIGN-PART DIGITS SIGN-PART = BLANKS [ SIGN ] BLANKS SIGN = + | - DIGITS = DIGIT { DIGIT } DIGIT = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
- Parameters:
T
- the input text- Returns:
- the resulting string
-
getint
Procedure getint.INTEGER-ITEM = SIGN-PART DIGITS SIGN-PART = BLANKS [ SIGN ] BLANKS SIGN = + | - DIGITS = DIGIT { DIGIT } DIGIT = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
The procedure locates an INTEGER ITEM. The function value is equal to the corresponding integer.- Parameters:
T
- the text reference- Returns:
- the resulting real
-
getRealItem
Scan the input text for a real item.REAL-ITEM = DECIMAL-ITEM [ EXPONENT ] | SIGN-PART EXPONENT DECIMAL-ITEM = INTEGER-ITEM [ FRACTION ] | SIGN-PART FRACTION INTEGER-ITEM = SIGN-PART DIGITS FRACTION = DECIMAL-MARK DIGITS SIGN-PART = BLANKS [ SIGN ] BLANKS EXPONENT = LOWTEN-CHARACTER INTEGER-ITEM SIGN = + | - DIGITS = DIGIT { DIGIT } DIGIT = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 LOWTEN-CHARACTER = & | ... DECIMAL-MARK = . | , BLANKS = { BLANK | TAB }
- Parameters:
T
- the input text- Returns:
- the resulting string
-
getreal
Procedure getreal.REAL-ITEM = DECIMAL-ITEM [ EXPONENT ] | SIGN-PART EXPONENT DECIMAL-ITEM = INTEGER-ITEM [ FRACTION ] | SIGN-PART FRACTION INTEGER-ITEM = SIGN-PART DIGITS FRACTION = DECIMAL-MARK DIGITS SIGN-PART = BLANKS [ SIGN ] BLANKS EXPONENT = LOWTEN-CHARACTER INTEGER-ITEM SIGN = + | - DIGITS = DIGIT { DIGIT } DIGIT = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 LOWTEN-CHARACTER = & | ... DECIMAL-MARK = . | , BLANKS = { BLANK | TAB }
The procedure locates a REAL ITEM. The function value is equal to or approximates to the corresponding number. An INTEGER ITEM exceeding a certain implementation-defined range may lose precision when converted to long real.- Parameters:
T
- the text reference- Returns:
- the resulting real
-
getFracItem
Scan the input text for a fraction item.GROUPED-ITEM = SIGN-PART GROUPS [ DECIMAL-MARK GROUPS ] | SIGN-PART DECIMAL-MARK GROUPS SIGN-PART = BLANKS [ SIGN ] BLANKS SIGN = + | - GROUPS = DIGITS { BLANK DIGITS } DIGITS = DIGIT { DIGIT } DIGIT = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
- Parameters:
T
- the input text- Returns:
- the resulting string
-
getfrac
Procedure getfrac.GROUPED-ITEM = SIGN-PART GROUPS [ DECIMAL-MARK GROUPS ] | SIGN-PART DECIMAL-MARK GROUPS SIGN-PART = BLANKS [ SIGN ] BLANKS SIGN = + | - GROUPS = DIGITS { BLANK DIGITS } DIGITS = DIGIT { DIGIT } DIGIT = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
The procedure locates a GROUPED ITEM. The function value is equal to the resulting integer. The digits of a GROUPED ITEM may be interspersed with BLANKS and a single DECIMAL MARK which are ignored by the procedure.- Parameters:
T
- the text reference- Returns:
- the resulting integer
-
putRealResult
Put the result of putReal type operation into the text T.- Parameters:
T
- the text referenceoutput
- the result of putReal
-
putResult
Put the result of put... operation into the text T.If the text frame is too short to contain the resulting numeric item, the text frame into which the number was to be edited is filled with asterisks. The final value of the position indicator of X is X.length+1.
- Parameters:
T
- the text references
- the result of put... operation
-
putint
Procedure putint.The value of the parameter is converted to an INTEGER ITEM which designates an integer equal to that value.
- Parameters:
T
- the text referencei
- the integer value to be edited
-
putfix
Procedure putfix.The resulting numeric item is an INTEGER ITEM if n=0 or a DECIMAL ITEM with a FRACTION of n digits if n>0. It designates a number equal to the value of r or an approximation to the value of r, correctly rounded to n decimal places. If n<0, a run-time error is caused.
- Parameters:
T
- the text referencer
- the long real value to be editedn
- the number of digits after decimal sign
-
putreal
Procedure putreal.The resulting numeric item is a REAL ITEM containing an EXPONENT with a fixed implementation-defined number of characters. The EXPONENT is preceded by a SIGN PART if n=0, or by an INTEGER ITEM with one digit if n=1, or if n>1, by a DECIMAL ITEM with an INTEGER ITEM of 1 digit only, and a fraction of n-1 digits. If n<0 a runtime error is caused.
- Parameters:
T
- the text referencer
- the long real value to be editedn
- the number of digits after decimal sign
-
putreal
Procedure putreal.- Parameters:
T
- the text referencer
- the real value to be editedn
- the number of digits after decimal sign
-
addPlussExponent
Real Edit Utility: Add plus exponent to the given string- Parameters:
s
- the given string- Returns:
- the resulting string
-
putfrac
Procedure putfrac.The resulting numeric item is a GROUPED ITEM with no DECIMAL MARK if n<=0, and with a DECIMAL MARK followed by total of n digits if n>0. Each digit group consists of 3 digits, except possibly the first one, and possibly the last one following a DECIMAL MARK. The numeric item is an exact representation of the number i * 10**(-n).
- Parameters:
T
- the text referenceval
- an integer valuen
- number of digits after a decimal mark
-