Differences between Acorn COMAL and UniCOMAL

This article is being updated periodically as points arise. We are very grateful to users upgrading from Acorn COMAL to UniCOMAL who contact us with queries as they happen upon problems. Please email support if you have any points to add or questions to ask.







Introduction

AcornSOFT COMAL as implemented on Acorn 8-bit computers, and used under emulation on both Acorn 32-bit machines and Apple Macs, differs from UniCOMAL in many ways. Several of the Acornsoft keywords are different from their equivalents in UniCOMAL, and worse still, there are instances where an UniComal keyword is used for something completely different in the Acorn implementation, as for example PAGE, which clears the text screen in UniComal but sets the origin location of the program in memory in Acorn-speak.

UniComal is a very much richer language than Acornsoft Comal, with a very wide range of professional-standard software development facilities. This can put Acornsoft Comal users at something of a disadvantage, since they find it rather difficult to locate the facilities they need in among all the ones they don't! Some of the UniComal features are most welcome, such as the command DISPLAY which lists a program segment without any line numbers, so that it can be stored as a text file and very easily merged with another program. A major difference is that all the structure-closing statements (ENDCASE, ENDIF etc.) are single keywords in UniComal, but must be entered as two separate keywords in Acornsoft COMAL. This makes for quite a bit of 'search and replace' work on files to be transferred.

The table at the end of this note shows some of the more obvious differences in syntax between UniComal and Acornsoft COMAL. Those structure-closing statements which are the same, apart from the extra space in the middle, have been ommitted, as have the many UniComal keywords which have no equivalent in AcornSoft COMAL. Those UniComal procedures or functions which are available in UniComal modules are listed in lower case letters, with the name of the module in brackets, while UniComal commands to handle MS-DOS operations, such as CHDIR and DIR, have been left out.






File Transfer and Translation

There is an UniCOMAL utility program on the downloads page, called acorncon, which attempts to convert Acorn COMAL source code files directly to UniCOMAL. Conversion is not complete, and there are many unsupported features of Acorn COMAL for which warnings are issued.

If you prefer to do it by hand, the following paragraphs may help:

Transferring files from Acorn systems to UniComal can be a long job, especially from 8-bit Acorn machines, with which it might be best to use a serial port link to a PC. Many schools with Econet systems having an Archimedes machine on the network, are able to manage file transfers between 5.25" Acorn format diskettes and 3.5" PC format diskettes by uploading the files to the fileserver from a 5.25" diskette drive attached to a BBC 'B' or Master 128, then copying back down onto a PC diskette using the Archimedes.

Archimedes users with RISC-OS 2 can use the "getfile.exe" and "putfile.exe" utilities supplied on the MS-DOS boot disc which comes with the PC Emulator. I preferred, however, the "MultiFS" program from ARXE, which allowed me to transfer files painlessly from Acorn ADFS (advanced disc filing system) discs to MS-DOS discs, and back again, using the RamDrive for temporary storage, all inside the RISC-OS desktop. RISC-OS 3 reads and writes PC diskettes normally, and thus removes the difficulties completely.

While trying to load the file into the PC, it is very useful to have a "sideways" text editor available alongside UniComal, so that the file being transferred can be easily edited to get it to the point where UniComal will accept it. You can use most TSR (terminate and stay resident) text editors for this. Windows users will find Notepad as good as any other text editor for this purpose.

Acornsoft COMAL to UniComal:

         *spool testprog
         LIST
         *spool
        MERGE "testprog.txt"  
             - use MERGE rather than ENTER  to build the 
               file up as errors are encountered.





Differences in Variable Types and Scopes

Loop Counters: Our thanks to a Scottish High School teacher who drew this very important difference to our attention. In Acorn COMAL, loop counter variables are global in scope. In other words, the value of the loop counter variable after the loop is terminated, is the last value reached during the execution of the loop. By contrast, in UniCOMAL, loop counter variables are local to the loop they are used in, and their values outside the loop are not assigned. The following example, which uses exactly the same syntax in each version of COMAL, may make the situation clearer:

Program Code AcornCOMAL
result
UniCOMAL
result
  100 counter# := 1
  110 FOR counter# := 1 TO 5 DO PRINT counter#  
  120 PRINT
  130 PRINT counter#
1
2
3
4
5

6
1
2
3
4
5

1

As you can see, the exit value of counter# in the Acorn version is 6, while in the UniCOMAL version it is 1. This will cause problems in converting from Acorn COMAL source code, and there may well be other, similar instances, in IF structures, for example, which we will post up as we come on them.

Strings: In both versions, the default length of a new string variable is 40 characters. In Acorn COMAL an attempt to store a longer string provokes a run-time error, while in UniCOMAL no error is reported: the string is truncated into the space available in the variable. So, in Acorn COMAL:

  100 sentence$ := "This sentence has more than 40 characters in it."

is accepted by the interpreter, but gives the error "String too long at line 100" when the program is run. The same line in UniCOMAL is accepted, but only the first 40 characters of the string are stored in the variable. The rest are lost. You can find a detailed article on string handling in UniCOMAL on this site, called Text Operations in UniCOMAL.




Graphics and System Modules

Many of the facilities which Acornsoft COMAL users take for granted, such as a teletext display, linked text and graphics displays, 4-channel sound etc., are either absent from UniComal or are implemented in the UniComal module library. The module facilities are fully described in the on-line help system: here, for example, is a list of the procedures and functions contained in the system module:-

arrowcolor, attrs$, autostarted#, bin$, closedir, comal87#, curattr#, curchar$, cursormode, defkey, diskfree#, environment$, eofdir#, equipment#, errorcolor, exitcode#, fkey, free#, getscreen, hex$, host$, inp#, inputpos, keycolors, opendir#, order#, out, peek#, poke, readdir$, setattr, setattrs, setchar, setexitcode, setscreen, showkeys, startpar$, termchar$, termchars, termpos#, textborder, textcolor, textmode, textwindow, volume$

The graphics module gives comprehensive VGA facilities, including a full Turtle Graphics command set, very useful for LOGO-style programming work with S1 and S2 pupils.






Keyword Differences between UniComal and Acornsoft COMAL.

This list is meant to help when trying to adapt Acorn Comal programs for use with UniComal, and vice versa. On the UniCOMAL side, brackets indicate procedures or functions from one of the module libraries: for example "clearscreen(system)" means "the clearscreen procedure in the system module".

UniComal                Acornsoft

CHAIN                   RUN filename
-                       CLEAR
clearscreen(system)     CLG
PAGE                    CLS
textcolor (system)      COLOUR
CON                     CONT
-                       COUNT
CURCOL                  POS
CURROW                  VPOS
CURSOR                  TAB(x,y)
SCAN                    DEBUG
-                       DEG
DOWNTO                  STEP -1
drawto(graphics)        DRAW
(sound module)          ENVELOPE 
ENTER "filename         *EXEC filename
XOR                     EOR
pencolor(graphics)      GCOL
-                       GET
KEY$                    INKEY
LOG                     LN
-                       LOG
textmode(system mod)    MODE
graphicscreen(graphics) MODE
moveto(graphics)        MOVE
-                       OLD
-                       PAGE
(graphics) procedures   PLOT
(graphics) functions    POINT
CURCOL                  POS
-                       RAD
RENUM                   RENUMBER
RND(1,endval)           RND(endval)
(sound) commands        SOUND
TIMER                   TIME
TRUE (= nonzero)        TRUE (= -1)
(assembler toolkit)     USR
CURROW                  VPOS

How do I .......

This section is meant specially for users moving to UniCOMAL from AcornSoft COMAL. See the FAQs page for more general information. Most of the "how do I?s" below use UniCOMAL code to illustrate the various points. If using Windows 95, it is very easy to run the code segments:

When referring to the UniCOMAL interactive help system, the following method is used:

    F1 -> System module -> bin$
     - which shows the path through the help system hyperlinks.

Clear the text screen?

    PAGE // Clears the text screen or sends form feed to printer.

Declare an integer variable?

    foreground# := 6  // the # symbol declares 'foreground' as integer

Keep printing on the same screen line?

    PRINT "No carriage return, please! ",  // comma rather than semicolon

Position the text cursor?

    PRINT AT row#, column# : text$   // The other way round from Acorn!

Get a 40-column display?

    // F1 -> System module -> textmode
    USE system
    textmode(2)   // 40 x25 coloured text display
    // Available text modes are:
    // mode#     Result:
    //     1     40 columns, 25 lines, black/white
    //     2     40 columns, 25 lines, color
    //     3     80 columns, 25 lines, black/white
    //     4     80 columns, 25 lines, color
    //     5     EGA: 80 columns, 43 lines; VGA: 80 columns, 50 lines

Choose a random number between 2 and 12?

    RANDOMIZE              // seeds the random number generator from the clock
    twodice# := RND(2,12)  // includes the endpoints 2 and 12 

Produce a teletext display?

Display colored and/or flashing text?

     // F1 -> System module -> textcolor -> color code overview
     USE system
     textcolor(foreground#, blink#, background#)
     //  0 <= fgnd#  <= 15   determines the foreground color of text.
     //  0 <= blink# <=  1   if TRUE  (=1) the text blinks, otherwise it does not.
     //  0 <= bgnd#  <=  7   determines the background color of the screen text.
     //  The colours are:
     //  0    black     8    grey
     //  1    blue      9    bright blue
     //  2    green     10   bright green
     //  3    cyan      11   bright cyan
     //  4    red       12   bright red
     //  5    magenta   13   bright magenta
     //  6    brown     14   yellow
     //  7    white     15   intense white

Draw simple 'graphics' on the text screen?

     // Use the text colour effects together with the 'box-drawing' characters
     // The box-drawing characters are listed in the help system,
     // F1 -> UniCOMAL Reference -> Keys -> Box
     USE system
     PAGE
     textcolor(1,0,6)   // Blue steady text on brown background
     draw_box(5,5,60,7)
     textcolor(7,0,0)   // Default steady white on default background
     END
     //
     PROC draw_box(x#, y#, columns#, rows#) CLOSED
       PRINT AT y#,x#: CHR$(218),   
       FOR c#:=1 TO columns#-2 DO PRINT CHR$(196),
       PRINT CHR$(191)
         FOR r#:=1 TO rows#-1 DO
         PRINT AT y#+r#,x#: CHR$(179),
         PRINT CHR$(179)
       ENDFOR
       PRINT AT y#+rows#,x#: CHR$(192),
       FOR c#:=1 TO columns#-2 DO PRINT CHR$(196),
       PRINT CHR$(217)
     ENDPROC draw_box

Latest update 08 May 2001 (email link update)