In order for this site to work correctly, and for us to improve the site, we need to store a small file (called a cookie) on your computer.
By continuing to use this website, you agree to our cookies and privacy policy.
  
Home page Home page Home page Home page
Pixel
Pixel Header R1 C1 Pixel
Pixel Header R2 C1 Pixel
Pixel Header R3 C1 Pixel
Pixel

RTP5 and RTP51

A Compuserve subscriber has asked how a program can compile another program and know if it failed? This spurred investigation into both RTP5 (the compiler) and RTP51 (the AREV ROS BFS) - the results of which are documented below. The RBASIC compiler is front-ended by RTP5 (REVMEDIA passim) and the calling syntax for this is documented by Revelation Technologies as


0001       call RTP5("", CODE, PARAMS, STATUS, TYPE)

where

  CODE      is the source code to be compiled
  PARAMS    is a dynamic array containing two fields,
            < 1 >  title to be displayed whilst compiling
            < 2 >  list of compile options
                   C    cut off Symbol Table,
                   E    for return reasons for failure (note not compilation
                        errors) in @FILE.ERROR instead of displaying an
                        error message
                   I    display Insert Message even if S set
                   N    Ignore freespace check
                   S    for Suppress informational message display
                        (Compiling *'s, Source Code Approaching Maximum Size
                        etc)
                   U    Do not buffer compiler

  STATUS    is a result flag (True or False)
  TYPE      is the type of compilation, M (code) or D (dictionary).

When RTP5 is called, the compiler attempts to compile the code in CODE and if it fails, it returns a list of errors in CODE which would have the following structure

     < 1 >              ERROR.LIST (a literal)
     < 2, 1 >           Line number of error
     < 2, 2 >           Error number
     < 2, 3 > et seq    Error Parameters
     < 3, et seq.....>  Repeat < 2 >

with the second field repeating for each compilation error. Thus if a program compiled with two bad statements, one on line 10 and one on line 35, CODE would contain ERROR.LIST : @FM : 10 : @VM : B102 : @FM : 35 : @VM : B102.

The codes stored in the SYS.MESSAGES file are not the codes used by RTP5 to indicate errors. For example, the compiler error B105 means "Variable has not been dimensioned or declared as a function", but the entry in SYS.MESSAGES for B105 is "The dBase file already exists - Do you wish to overwrite it?". Rather the codes and their meanings are stored in the operating system file REVERROR.000 which is in AREV ROS format. However as there is no ROS media map for REVBOOT accessing this proves difficult.

Whilst it is possible to setvolume to REVBOOT and create an artificial REVMEDIA entry for REVERROR, this is cumbersome. It is far easier to simply construct a file handle for the REVERROR file and then to read directly from the file using this file handle. Unfortunately if this is attempted the system falls over with an RTP51 VNAV message. To prevent this it is necessary to first ensure that RTP51 is correctly installed by calling it directly with an install code. Once this has been done it is possible to read the error messages directly from file and then interpret the messages accordingly.

Note however that to people who have never been exposed to Rev G2.B the format of these error message records can be a little peculiar. Essentially the first character of each error message field is an instruction, H means output the following text without a terminating line feed, E means the same with a line feed, A means insert a variable here, L means insert a line feed. Using this short guide, a simple compile and syntax check program could be created as follows :-


0001    /*
0002    Author    AMcA
0003    Date      Nov 1991
0004    Purpose   To compile programs and display error messages where appropriate
0005    Copyright Sprezzatura Ltd 1991. All Rights Reserved
0006    */
0007  
0008    CODE = ""
0009    *  Firstly prompt for code to be compiled
0010    call msg("Enter Code & or ; Delimited", "R", CODE, "")
0011    convert "&;" to @FM : @FM in CODE
0012    /*
0013      RTP5 objects to the lack of an END statement so ensure that there is one
0014      there!
0015    */
0016    CODE<-1> = "END"
0017    * Compile the code
0018    call rtp5("", CODE, "Demo" : @FM : "S" , STATUS, "M")
0019    /*
0020    If status is not set then the compile has failed and the reason will be
0021    returned in CODE. NB this erases whatever was in CODE!
0022    */
0023    if STATUS else
0024      * Ensure that RTP51 is available by calling with and install (22) code
0025      call RTP51(22, "RTP51", "", "", "", "", STATUS)
0026      /*
0027      Now construct an RTP51 file variable. These comprise the filing
0028      system, a value mark and the full dos file specification with an
0029      extension equal to the modulo, with a special modulo of 0 for
0030      dictionary files
0031      */
0032      REV_ERR_FILE = "RTP5ýC:\AREV2_1\REVERROR.0"
0033      * Remember, the first error is a literal not an error
0034      ERR_CNT = count(CODE, @FM) + 1
0035      ERR_MSG = ""
0036      for ERR = 2 to ERR_CNT
0037         LINE = CODE<ERR, 1>
0038         ERR_NO = CODE<ERR, 2>
0039         read ERR_REC from REV_ERR_FILE, ERR_NO then
0040           MARK = 0  ; POS = 0 ; VAR = 3
0041           loop
0042              remove NL from ERR_REC at POS setting MARK
0043              * Now see how to interpret line
0044              if NL then
0045                FIRST_CHAR = NEXT_LINE[1,1]
0046                begin case
0047                   case FIRST_CHAR = "E"
0048                     ERR_MSG<-1> = NEXT_LINE[2,99]
0049                   case FIRST_CHAR = "A"
0050                     /*
0051                     Note, MV 3 onwards contains variables to include in the
0052                     message
0053                     */
0054                     ERR_MSG := CODE<ERR, VAR>
0055                     VAR += 1
0056                   case FIRST_CHAR = "H"
0057                     ERR_MSG := NEXT_LINE[2,99]
0058                   case FIRST_CHAR = "L"
0059                     ERR_MSG := @FM
0060                end case
0061              end
0062           while MARK do
0063           repeat
0064         end
0065      next
0066      * And finally display the assembled error message
0067      call msg(ERR_MSG, "", "", "")
0068    end

(Volume 3, Issue 7, Pages 5-7)
Pixel
Pixel Footer R1 C1 Pixel
Pixel
Pixel
Pixel