Module Simula

Class RTS_DEC_Lib

All Implemented Interfaces:
Runnable

public class RTS_DEC_Lib extends RTS_CLASS
Additional System class DEC_Lib.

A set of utility procedures from DEC Handbook.

Link to GitHub: Source File.

Author:
Øystein Myhre Andersen
  • Field Details

    • DECLIB

      private static RTS_DEC_Lib DECLIB
      A local static instance of RTS_DEC_Lib.
  • Constructor Details

    • RTS_DEC_Lib

      public RTS_DEC_Lib(RTS_RTObject staticLink)
      Normal Constructor
      Parameters:
      staticLink - static link
  • Method Details

    • _STM

      public RTS_DEC_Lib _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 class RTS_RTObject
      Returns:
      a pointer to this _RTObject
    • abort

      public static void abort(RTS_TXT mess)
      DEC_Lib Procedure abort.
       procedure abort(message); ! Stop execution. ;
      
       Abort will print the message on the error device and then call
       terminate_program.
       
      Parameters:
      mess - a descriptive message
    • change

      public static boolean change(RTS_RTObject.RTS_NAME<RTS_TXT> master, RTS_TXT oldtext, RTS_TXT newtext)
      DEC_Lib Procedure change.
       boolean procedure change(master,oldtext,newtext);   ! Replacing Subtexts. ;
      
       Starting at master.pos, the procedure change will search for the subtext oldtext.
       
       If not found, master remains unchanged and the procedure value is false.
       The position indicator is set to length+1, i.e. master.setpos(0);
       
       If found, oldtext will be replaced by newtext and the procedure value is true.
       If oldtext.length >= newtext.length then master will denote a subtext of the original master text,
       otherwise master will denote a new text object.
       The position indicator is set to first character following newtext within the resulting master.
       
       Changing all occurrences of oldtext to newtext may be done with the following procedure;
      
                procedure changeAll(master,oldtext,newtext); name master; text master,oldtext,newtext;
                begin text local;
                   local:- master;
                   while local.more do change(local,oldtext,newtext);
                   master:- local
                end;
               
       The position indicator 'pos' of master is set to first character after the substituted text.
       If not found, 'pos' is unaltered.
      
          boolean procedure change(master,oldtext,newtext); name master; text master,oldtext,newtext; begin
              text local; integer p;
              local:-master;
              p:=search(local,oldtext);
              if p <= local.length then begin
                  change:=true;
                  if oldtext.length>=newtext.length then begin
                      local.sub(p,newtext.length):=newtext;
                      if oldtext.length>newtext.length then begin
                          from(local,p+newtext.length):=from(local,p+oldtext.length);
                          local:-local.sub(1,local.length-oldtext.length+newtext.length)
                      end
                  end else local:-local.sub(1,p-1) & newtext & from(local,p+oldtext.length);
                  local.setpos(p+newtext.length);
                  master:-local
              end else master.setpos(0)
          end;
       
       
      Parameters:
      master - argument
      oldtext - argument
      newtext - argument
      Returns:
      false: no change has occurred
    • checkextension

      public static RTS_TXT checkextension(RTS_TXT fileName, RTS_TXT defaultextension)
      DEC_Lib Procedure checkextension.
       text procedure checkextension(fileName,defaultextension);
      
       The procedure checkextension may be used to add a default extension to
       file specifications not containing a dot ('.').  I.e.
         fileName:- copy("myFile"); fileName:- checkextension(fileName,".txt");
               will give fileName the value "myFile.txt", while
         fileName:- copy("myFile.doc"); fileName:- checkextension(fileName,".txt");
               will leave fileName unaltered.
       
       
      Parameters:
      fileName - argument
      defaultextension - argument
      Returns:
      the resulting text
    • checkint

      public static int checkint(RTS_RTObject.RTS_NAME<RTS_TXT> t)
      DEC_Lib Procedure checkint.
       <type> procedure check<type>(t); name t; text t; where <type> ::= real | int | frac
       
      check<type> analyses the text t from t.pos and on. If a get<Number> operation from this position is legal the returned value is +1.

      If it would give an error - then if the remaining text string is blank, the result is 0, else -1.

      pos is placed after a legal item (+1), after the first nonblank illegal character (-1) or after the text if the rest is empty (0).

      NOTE: The current implementation will place t.pos after a complete real item, even if it overflows. Real underflow produces +0, overflow Infinity, both of which are treated as legal results

      Parameters:
      t - name reference to argument text
      Returns:
      resulting code +1:OK else error
    • checkfrac

      public static int checkfrac(RTS_RTObject.RTS_NAME<RTS_TXT> t)
      DEC_Lib Procedure checkfrac. See checkint(RTS_NAME<RTS_TXT>)
      Parameters:
      t - name reference to argument text
      Returns:
      resulting code +1:OK else error
    • checkreal

      public static int checkreal(RTS_RTObject.RTS_NAME<RTS_TXT> t)
      DEC_Lib Procedure checkrealc. See checkint(RTS_NAME<RTS_TXT>)
      Parameters:
      t - name reference to argument text
      Returns:
      resulting code +1:OK else error
    • checkNumber

      private static int checkNumber(RTS_RTObject.RTS_NAME<RTS_TXT> t, RTS_DEC_Lib.NumberChecker numberChecker)
      Check number using the given NumberChecker.

      Each check number produre analyses the text t from t.pos and on. If a get<number> operation from this position is legal the returned value is +1.

      If it would give an error - then if the remaining text string is blank, the result is 0, else -1.

          pos is placed after a legal item (+1),
          after the first nonblank illegal character (-1)
          or after the text if the rest is empty (0).
       
      NOTE: The current implementation will place t.pos after a complete real item, even if it overflows. Real underflow produces +0, overflow Infinity, both of which are treated as legal results
      Parameters:
      t - the text to check
      numberChecker - the given number checker
      Returns:
      code (see above)
    • compress

      public static RTS_TXT compress(RTS_TXT t, char c)
      DEC_Lib Procedure compress.
       text procedure compress(t,c); text t; character c;
       
       Removes all occurrences of the character c in the text t.
      
       The procedure compress returns notext (if t contains no other characters than
       a number of characters = c), or a reference to an initial subtext of t
       (altered) which contains all characters of t not = c. The part of t after
       this subtext is unchanged.
       
       Example:  t1:-copy("AxBxCxDx");  t2:-compress(t1,'x');
           gives t1="ABCDCxDx", t2==t1.sub(1,4), t2="ABCD".
       
       
      Parameters:
      t - argument text
      c - search character
      Returns:
      the resulting text
    • conc

      public static RTS_TXT conc(RTS_TXT t1, RTS_TXT t2)
      DEC_Lib Procedure conc.
       text procedure conc(t1,t2); text t1,t2;
       text procedure conc2(t1,t2); text t1,t2;
       text procedure conc3(t1,t2,t3); text t1,t2,t3;
       text procedure conc4(t1,t2,t3,t4); text t1,t2,t3,t4;
       text procedure conc5(t1,t2,t3,t4,t5); text t1,t2,t3,t4,t5;
       
       Concatenate texts. Provided for compatibility only, use the text
       concatenation operator & instead!
       
      Parameters:
      t1 - argument t1
      t2 - argument t2
      Returns:
      the concatenated text
    • conc2

      public static RTS_TXT conc2(RTS_TXT t1, RTS_TXT t2)
      DEC_Lib Procedure conc2. See conc(RTS_TXT, RTS_TXT)
      Parameters:
      t1 - argument t1
      t2 - argument t2
      Returns:
      the concatenated text
    • conc3

      public static RTS_TXT conc3(RTS_TXT t1, RTS_TXT t2, RTS_TXT t3)
      DEC_Lib Procedure conc3. See conc(RTS_TXT, RTS_TXT)
      Parameters:
      t1 - argument t1
      t2 - argument t2
      t3 - argument t3
      Returns:
      the concatenated text
    • conc4

      public static RTS_TXT conc4(RTS_TXT t1, RTS_TXT t2, RTS_TXT t3, RTS_TXT t4)
      DEC_Lib Procedure conc4. See conc(RTS_TXT, RTS_TXT)
      Parameters:
      t1 - argument t1
      t2 - argument t2
      t3 - argument t3
      t4 - argument t4
      Returns:
      the concatenated text
    • conc5

      public static RTS_TXT conc5(RTS_TXT t1, RTS_TXT t2, RTS_TXT t3, RTS_TXT t4, RTS_TXT t5)
      DEC_Lib Procedure conc5. See conc(RTS_TXT, RTS_TXT)
      Parameters:
      t1 - argument t1
      t2 - argument t2
      t3 - argument t3
      t4 - argument t4
      t5 - argument t5
      Returns:
      the concatenated text
    • cptime

      public static double cptime()
      DEC_Lib Procedure cptime.
       real procedure cptime;
      
       Returns total CPU time spent since the beginning of the SIMULA program
       execution, expressed in seconds. Provided for compatibility, use cputime
       instead!
      
       real procedure cptime; begin cptime:= cputime; end;
       
      Returns:
      seconds since start of program
    • dayno

      public static int dayno()
      DEC_Lib Procedure datno-
       integer procedure dayno;
       
      Returns:
      the day number in current month.
    • daytime

      public static RTS_TXT daytime()
      DEC_Lib Procedure daytime.
       text procedure daytime;
      
       Returns a reference to a new text of length 8 with
       contents: "hh:mm:ss"
       
               where hh        is hours
                     mm        is minutes
                     ss        is seconds.
               at the time of the call.
       
      Returns:
      the resulting text
    • depchar

      public static void depchar(RTS_TXT t, int p, char c)
      DEC_Lib Procedure depchar.
       procedure depchar(t,p,c); text t; integer p; character c;
      
       Deposits the character c in the text t at position p. If p is out of range,
       no action will be taken;
       
       This is a safe version of S-port standard procedure StoreChar.
      
          procedure depchar(t,p,c); text t; integer p; character c;
          if p>0 and p<=t.length
          then t.sub(p,1).putchar(c);
       
       
      Parameters:
      t - a text reference
      p - the text position in which the character is stored
      c - a character
    • enterdebug

      public static void enterdebug(boolean maycontinue)
      DEC_Lib Procedure enterdebug
       procedure enterdebug(maycontinue); boolean maycontinue; ! Enter SIMOB ;
      
       Enterdebug will activate SIMOB (if present). After SIMOB session, the
       execution will either continue (maycontinue true) or it will terminate
       (maycontinue false).
      
          procedure enterdebug(maycontinue); boolean maycontinue;
          begin  ... enter SIMOB
                 if not maycontinue then terminate_program;
          end;
       
      Parameters:
      maycontinue - true: the program may continue after SIMOB session
    • exit

      public static void exit(int code)
      DEC_Lib Procedure exit.
       procedure exit(n); integer n;
      
         n=0: Terminate program immediately, with no further action.
              No files closed.
         n=1: Terminate program as if final end was reached, i.e. all
              open files are closed (and a message given for each).
         n=2: Equivalent to enterdebug(true).
      
         Other values of n are reserved for extensions.
      
          procedure exit(n); integer n;
          begin
                if n=0 then ... stop execution;
                if n=1 then terminate_program;
                if n=2 then enterdebug(true)
                else begin
                   outtext("Parameter to exit out of range (0,2)");
                   outimage;
                   terminate_program;
                end;
          end;
       
      Parameters:
      code - integer value
    • fetchar

      public static char fetchar(RTS_TXT t, int p)
      DEC_Lib Procedure fetchar.
       character procedure fetchar(t,p); text t; integer p;
      
       Returns the p'th character from t, if p is within range, otherwise '!0!'.
       
       This is a safe version of S-port standard procedure LoadChar.
      
          character procedure fetchar(t,p); text t; integer p;
          if p>0 and p<=t.length then fetchar:= t.sub(p,1).getchar;
      
       
      Parameters:
      t - a text reference
      p - the text position in which the character is stored
      Returns:
      the character at position p
    • findtrigger

      public static char findtrigger(RTS_RTObject.RTS_NAME<RTS_TXT> master, RTS_TXT triggers)
      DEC_Lib Procedure findtrigger.
       character procedure findtrigger(master,triggers); name master; text master,triggers;
      
       Starting from current master.pos, find first occurrence of any of the
       characters in triggers.;
      
       character procedure findtrigger(master,triggers); name master; text master,triggers;
       begin character c; text t;
             t:- master; while t.More do
             begin c:= t.getchar; triggers.setpos(1);
                   if scanto(triggers,c) =/= triggers then
                   begin comment c found in triggers; findtrigger1:= c;
                         goto out;
                   end
             end loop;
        out: master.setpos(t.pos);
       end;
       
      Parameters:
      master - argument
      triggers - argument
      Returns:
      the resulting character
    • from

      public static RTS_TXT from(RTS_TXT t, int p)
      DEC_Lib Procedure from.
       text procedure from(t,p); text t; integer p;
      
       Returns a reference to the longest subtext of t starting at pos = p.
      
       text procedure from(t,p); text t; integer p;
       if p<=t.Length then from :- if p<=0 then t else t.Sub(p,t.Length-p+1);
      
       
      Parameters:
      t - argument text
      p - start pos
      Returns:
      the resulting text
    • front

      public static RTS_TXT front(RTS_TXT t)
      DEC_Lib Procedure front.
       text procedure front(t); text t;
      
       Returns a reference to the longest subtext of t before pos.
      
       text procedure front(t); text t; if t=/=notext then front:-t.sub(1,t.pos-1);
       
       
      Parameters:
      t - argument text
      Returns:
      the resulting text
    • frontcompare

      public static boolean frontcompare(RTS_TXT string, RTS_TXT config)
      DEC_Lib Procedure frontcompare.
       boolean procedure frontcompare(string,config); text string,config;
      
       Starting at current pos, does string begin with a substring equal to config ?
      
         boolean procedure frontcompare(string,config); text string,config;
         if string.Length - string.pos+1 >= config.Length then
         frontcompare:= string.Sub(string.pos,config.Length) = config;
       
       
      Parameters:
      string - argument
      config - argument
      Returns:
      true: codition holds
    • frontstrip

      public static RTS_TXT frontstrip(RTS_TXT t)
      DEC_Lib Procedure frontstrip-
       text procedure frontstrip(t); text t;
      
       Returns a reference to the longest subtext of t starting with the first
       non-blank character.
       
       
      Parameters:
      t - argument text
      Returns:
      the resulting text
    • getitem

      public static RTS_TXT getitem(RTS_RTObject.RTS_NAME<RTS_TXT> tt)
      DEC_Lib Procedure getitem.
       text procedure getitem(tt); name tt; text tt;
      
       Skips any blanks or tabs, starting at tt.pos. If tt.more holds then, an item
       is identified according to the following rules:
      
       a) If the first following character is a letter (a-z,A-Z), an identifier is
       found. The identifier consists of the initial letter and any following
       letters and/or decimal digits.
      
       b) If the first character is a digit, we have a numeric item, consisting of a
       string of digits with at most one decimal point "." included.
      
       c) Any other character except blank or tab forms an item on its own.
       
       Example: "IF car.wheel_size > 13.5" will be split into the items "IF", "car",
       ".", "wheel", "_", "size", ">", "13.5" via successive calls to GETITEM.
      
       The value of getitem is a subtext reference to the item within tt, or notext
       if no item can be found starting at tt.pos. tt.pos will be placed after the
       item.
      
      
       text procedure getitem(tt); name tt; text tt; if tt =/= notext then
       begin character window; integer startpos; text t;
       
             character procedure getCharacter;
             if t.more then getCharacter:= window:=t.getchar else goto out;
       
             boolean procedure idchar(c); character c; idchar:= letter(c) or digit(c);
       
             t:- tt; t.setpos(tt.pos); startpos:= t.length+1; getCharacter;
             while window = ' ' or window = char(9) do getCharacter;
             startpos:= t.pos-1;
             if not letter(window) then
             begin if digit(window) then while digit(getCharacter) do;
                   if window = '.' then while digit(getCharacter) do;
             end else while idchar(getCharacter) do;
             if t.pos > startpos + 1 then t.setpos(t.pos-1);
        out: getitem1 :- t.sub(startpos,t.pos-startpos);
             tt.setpos(t.pos)
       end;
      
       
      Parameters:
      tt - argument text
      Returns:
      the resulting text
    • GETITEM

      private static RTS_TXT GETITEM(RTS_TXT TXT)
      Starting at pos, get next item in the given text.
      Parameters:
      TXT - the given text
      Returns:
      the resulting item
    • hash

      public static int hash(RTS_TXT t, int n)
      DEC_Lib Procedure hash.
       integer procedure hash(t,n); text t; integer n;
      
       Procedure HASH returns a calculated hash value, in the range (0:n-1), from a
       given text t. The result is taken modulo n before return.
       
       It is recommended to choose n as a prime number.
      
          integer procedure hash(t,n); text t; integer n; begin
              text tstrip; integer a;
              tstrip:- frontstrip(t.Strip);
              if tstrip == notext then hash:= mod(t.length,n) else begin
                  a:= rank(tstrip.getchar);
                  if tstrip.length > 3 then begin
                      a:= a +   8*rank(tstrip.getchar);
                      a:= a +  64*rank(tstrip.getchar)
                  end;
                  tstrip.setpos(tstrip.length);
                  a:= a + 512*rank(tstrip.getchar) + t.length;
                  hash:= mod(a,n);
              end
          end of hash;
      
       
      Parameters:
      t - the argument text
      n - the argument n
      Returns:
      resulting hash value, in the range (0:n-1)
    • initem

      public static RTS_TXT initem(RTS_File f)
      DEC_Lib Procedure initem.
       text procedure initem(fileref); ref(file) fileref; begin
      
       The parameter is formally ref(file), but should refer an infile, directfile,
       inbytefile or directbytefile (otherwise notext is returned). Same as getitem
       for files.
       
       On infiles or directfiles, lastitem is called first. Notext is returned, if
       (a) fileref is none, (b) fileref does not point to a legal file object (see
       above), or (c) the remainder of the file is spaces and/or TABs. Note, that
       since no copying is done, a call on initem may destroy previously located
       items, if they are not copied by the program, since inimage may be invoked.
      
       NOTE: Initem is extended to cover bytefiles;
             it will then return a single character item.
      
         text procedure initem(fileref); ref(file) fileref; begin
             text res; integer i;
             inspect fileref
               when infile do
                    if not lastitem then res:-getitem(image)
               when directfile do
                    if not lastitem then res:-getitem(image)
               when inbytefile do begin
                    res:-blanks(1); i:=rank('!9!');
                    while i=rank(' ') or i=rank('!9!') !TAB; do i:=inbyte;
                    res.sub(1,1).putchar(char(i));
               end
               when directbytefile do begin
                    res:-blanks(1); i:=rank('!9!');
                    while i=rank(' ') or i=rank('!9!') !TAB; do i:=inbyte;
                    res.sub(1,1).putchar(char(i));
               end;
               initem:-res;
         end;
       
       
      Parameters:
      f - argument File
      Returns:
      the resulting text
    • insinglechar

      public static char insinglechar()
      DEC_Lib Procedure insinglechar.
       character procedure insinglechar;
       
       Returns next input character from sysin (after last inimage) without waiting
       for break character. A subsequent inimage will begin reading after the last
       character which has been input with insinglechar.
       
       The use of this routine depends on runtime option USE_CONSOLE.
       If it is not set a runtime error will occur.
       
       
      Returns:
      single character
    • linecount

      public static int linecount(RTS_Printfile pf)
      DEC_Lib Procedure linecount.
       integer procedure linecount(pfil); ref(PrintFile) pfil; begin
           if pfil==none then linecount:=-1
           else if not pfil.isOpen then linecount:=-2
           else begin
               --  return current linesperpage setting
               integer lpp; lpp:=linesperpage(0); linesperpage(lpp);
               linecount:=lpp;
           end;
       end;
       
       
      Parameters:
      pf - argument Printfile
      Returns:
      resulting lpp or code
    • lowc

      public static char lowc(char c)
      DEC_Lib Procedure lowc.
       character procedure lowc(c); character c;
      
       Returns uppercase character as lowercase equivalent, other characters
       unchanged.
      
         character procedure lowc(c); character c;
         lowc:= if not Letter(c) then c else
                if c > 'z' then
                    char(rank(c)-rank('A')+rank('a')) else c;
       
      Parameters:
      c - argument character
      Returns:
      the lower case versjon
    • maketext

      public static RTS_TXT maketext(char c, int n)
      DEC_Lib Procedure maketext.
       text procedure maketext(ch,n); character ch; integer n;
      
       Return a text object of length n, filled with character ch.
      
       text procedure maketext(ch,n); character ch; integer n; if n > 0 then begin
       text t; t:-blanks(n); while t.more do t.putchar(ch); t.setpos(1);
       maketext:-t; end;
      
       
      Parameters:
      c - argument character
      n - text length
      Returns:
      resulting text value
    • puttext

      public static boolean puttext(RTS_RTObject.RTS_NAME<RTS_TXT> oldstring, RTS_TXT newstring)
      DEC_Lib Procedure puttext.
       boolean procedure puttext(oldstring,newstring); name oldstring; text
       oldstring,newstring;
      
       Puts the (short) text newstring into the (longer) text oldstring. Newstring
       is put at POS in oldstring, and POS of oldstring is moved after the end of
       the new substring.
       
       Returns false if there was not room for the new string, or if trying to
       modify a Constant text.
      
        boolean procedure puttext(oldstring,newstring); name oldstring; text oldstring,newstring;
        begin text s;
            s:-oldstring;
            if s.pos+newstring.length-1 <= s.length 
               and then not s.constant
            then begin
                puttext:=true;
                s.sub(s.pos,newstring.length):=newstring;
                s.setpos(s.pos+newstring.length)
                oldstring.setpos(s.pos)
            end;
        end;
       
       
      Parameters:
      oldstring - argument old string
      newstring - argument new string
      Returns:
      tthe resulting text
    • rest

      public static RTS_TXT rest(RTS_TXT t)
      DEC_Lib Procedure rest.
       text procedure rest(t); text t;
      
       Returns a subtext reference of a text starting at pos.
      
       text procedure rest(t); text t; rest :- t.sub(t.pos,t.length+1-t.pos);
      
       
      Parameters:
      t - argument text
      Returns:
      resulting text
    • scanchar

      public static char scanchar(RTS_RTObject.RTS_NAME<RTS_TXT> t)
      DEC_Lib Procedure scanchar.
       character procedure scanchar(t); name t; text t;
      
       Safe version of GETCHAR. Will not give RTS error, just returns char(0) if not
       t.more.
      
       character procedure scanchar(t); name t; text t;
       scanchar:= if t.more then t.getchar else char(0);
       
       
      Parameters:
      t - argument text
      Returns:
      resulting character value
    • scanfrac

      public static int scanfrac(RTS_RTObject.RTS_NAME<RTS_TXT> t)
      DEC_Lib Procedure scanfrac.
       integer procedure scanfrac(t); name t; text t;
       
       Scanfrac is similar to getfrac, but differs in two principal ways:
       
       1) It looks for an item starting at t.pos
       
       2) The handling of error conditions due to bad data is different. Scanfrac
       returns the value of the next grouped item if any. If no such item is found,
       'minint' is returned.
       
       t.pos will only be moved if de-editing was successful.
       
       
      Parameters:
      t - argument text
      Returns:
      the resulting integer value
    • scanint

      public static int scanint(RTS_RTObject.RTS_NAME<RTS_TXT> t)
      DEC_Lib Procedure scanint.
       integer procedure scanint(t); name t; text t;
      
       Scanint is similar to GETINT, but differs in two principal ways:
       
       1) It looks for an item starting at T.pos
       
       2) The handling of error conditions due to bad data is different. Scanint
       returns the value of the next integer item if any. If no such item is found,
       'minint' is returned.
       
       t.pos will only be moved if de-editing was successful.
      
          integer procedure scanint(t); name t; text t;
          begin
            EXTERNAL text procedure rest;
            EXTERNAL integer procedure checkint,maxint;
            text s;  integer i;
            s:-rest(t);
            i:=checkint(s);
            if i=1 then begin
              scanint:=s.Getint;
              t.setpos(t.pos+s.pos-1)
            end else scanint:=Minint
          end;
      
       
      Parameters:
      t - argument text
      Returns:
      the resulting integer value
    • scanreal

      public static double scanreal(RTS_RTObject.RTS_NAME<RTS_TXT> t)
      DEC_Lib Procedure scanreal.
       long real procedure scanreal(t); name t; text t;
      
       Scanreal is similar to GETREAL, but differs in two principal ways:
       
       1) It looks for an item starting at T.pos
       
       2) The handling of error conditions due to bad data is different. Scanreal
       returns the value of the next real item if any. If no such item is found,
       'minreal' is returned.
       
       t.pos will only be moved if de-editing was successful.
      
          comment -1&33 should be the most negative real value;
          long real procedure scanreal(t);  name t;  text t;
          begin
            EXTERNAL text procedure rest;
            EXTERNAL integer procedure checkreal;
            text s;  integer i;
            s:-rest(t);
            i:=checkreal(s);
            if i=1 then begin scanreal:=s.Getreal;
                              t.setpos(t.pos+s.pos-1)
                   end else scanreal:=Minreal;
          end;
       
       
      Parameters:
      t - argument text
      Returns:
      resulting long real value
    • scanto

      public static RTS_TXT scanto(RTS_RTObject.RTS_NAME<RTS_TXT> t, char c)
      DEC_Lib Procedure scanto.
       text procedure scanto(tt,c); name tt; text tt; character c;
      
       Scans from tt.pos until the next occurrence of the character c. Places tt.pos
       after the character found.
       
       The function value of scan is the text starting at the initial tt.pos and not
       including the character c found.
       
       If no character c is found, tt.pos will be = tt.length+1, and scan denotes
       the rest of tt starting at the initial tt.pos.
      
        text procedure scanto(tt,c); name tt; text tt; character c; begin
            text t; integer p;
            t:- tt; p:= t.pos;
            while t.more do
              if t.getchar = c then begin
                  scanto:- t.sub(p,t.pos-p-1);
                  goto out;
              end;
            scanto:- from(t,p);
            out: tt.setpos(t.pos);
          end of scanto;
       
       
      Parameters:
      t - argument text
      c - stop character c
      Returns:
      the resulting text
    • search

      public static int search(RTS_TXT t1, RTS_TXT t2)
      DEC_Lib Procedure search.
       integer procedure search(t1,t2); text t1,t2;
      
       Search: find first subtext = t2 from t1.pos;
       Return: The pos indicator of first character of subtext within t1.
               If not found return t1.length+1
       
      Parameters:
      t1 - master text
      t2 - text to be searched for
      Returns:
      resulting pos
    • skip

      public static RTS_TXT skip(RTS_RTObject.RTS_NAME<RTS_TXT> t, char c)
      DEC_Lib Procedure skip.
       text procedure skip(tt,c); name tt; text tt; character c; begin
      
       If, starting at tt.pos, a sequence of characters = c is found, then tt.pos is
       moved past these characters, otherwise tt.pos is unaltered.
       
       The function value of skip is rest(tt) (after changing tt.pos).
      
         text procedure skip(tt,c); name tt; text tt; character c; begin
             text t; t:- tt;
             while t.more do if t.getchar ne c then begin
                 t.setpos(t.pos-1);
                 skip1:- t.sub(t.pos,t.length-t.pos+1);
                 goto out
             end;
             out: tt.setpos(t.pos)
         end of skip;
      
       
      Parameters:
      t - argument text
      c - argument character
      Returns:
      the resulting text
    • startpos

      public static int startpos(RTS_TXT t)
      DEC_Lib Procedure startpos.
       integer procedure startpos(t); text t;
      
       startpos returns the starting position of t within t.main. Provided for
       compatibility only;
      
       integer procedure startpos(t); text t; begin startpos:=t.start; end;
      
       
      Parameters:
      t - argument text
      Returns:
      starting position of t within t.main
    • today

      public static RTS_TXT today()
      DEC_Lib Procedure today.
       text procedure today;
      
       Returns a reference to a text object of length 10 with contents "yyyy-mm-nn"
       where yyyy is year, mm is month(in digits 01-12), nn is day (in digits
       01-31). This is the internationally standardized format for dates.
      
       text procedure today; today:-datetime.sub(1,10);
       
      Returns:
      the resulting text
    • tsub

      public static RTS_TXT tsub(RTS_TXT t, int p, int l)
      DEC_Lib Procedure tsub.
       text procedure tsub(t,p,l); text t; integer p,l;
      
       tsub is a safe variant of sub. Parameters which give an error in sub will
       return notext instead.
      
         text procedure tsub(t,p,l); text t; integer p,l;
         if p >= 1 and l >= 0 and p+l <= t.length + 1 then
             tsub:- t.sub(p,l);
      
       
      Parameters:
      t - argument text
      p - argument pos
      l - argument length
      Returns:
      the resulting text
    • upc

      public static char upc(char c)
      DEC_Lib Procedure upc.
       character procedure upc(c); character c;
      
       Returns lowercase character as uppercase equivalent, other characters
       unchanged.
      
          character procedure upc(c); character c;
             upc:= if not Letter(c) then c else
                   if c > 'Z' then
                      char(rank(c)-rank('a')+rank('A')) else c;
      
       
      Parameters:
      c - argument character
      Returns:
      the upper case versjon
    • upcompare

      public static boolean upcompare(RTS_TXT master, RTS_TXT test)
      DEC_Lib Procedure upcompare.
       boolean procedure upcompare(master,test);
      
      
               Upcompare returns true if the contents
               of TEST is equal to the next TEST.length characters of MASTER,
               counted from current MASTER.pos.
               The MASTER characters will be converted to upper case
               before comparison (without changing the MASTER text).
               Note that the TEST text will not be converted.
               Thus
      
               MASTER          TEST            UPCOMPARE
      
               BEGIN           BEG             true
               BEGIN           beg             false
               begin           BEG             true
               begin           beg             false
               xxxxx           BEG             false
      
               assuming that MASTER.pos = 1.
               If TEST == notext the result will always be true.
      
      
          boolean procedure upcompare(master,test); text master,test;
          if master.pos + test.length <= master.length + 1 then begin
              character cmaster,ctest;
              integer shift;
              shift:= rank('a') - rank('A');
              while master.more and test.more and cmaster = ctest do begin
                  cmaster:= master.getchar;
                  ctest:= test.getchar;
                  if (if cmaster > 'Z' then Letter(cmaster) else FALSE)
                      then cmaster:= char(rank(cmaster) - shift);
              end loop;
          Out:upcompare:= cmaster = ctest;
          end;
      
       
      Parameters:
      master - argument master
      test - argument test
      Returns:
      true if condition holds
    • upto

      public static RTS_TXT upto(RTS_TXT t, int p)
      DEC_Lib Procedure upto.
       text procedure upto(t,p); text t; integer p;
      
       Returns a reference to the longest subtext of T before pos = p.
      
         text procedure upto(t,p); text t; integer p;
         if i>0 then upto :- if p>t.length then t else t.sub(1,p-1);
      
       
      Parameters:
      t - argument text
      p - pos limit
      Returns:
      the resulting text