menu page

COMAL KEYWORDS: (version 0.14) REVISED

NOTE :- In all that follows items in [] are optional. If used do NOT type the []. Items in <> are supplied by the user. The <> are NOT typed. All other items including punctuation and () must be typed as shown.
SPACES ARE SIGNIFICANT.

Line number range 0001 to 9999
LOAD"C64 COMAL 0.14",8,1
LIST gives
10 SYS(2063)
RUN gives
9902 BYTES FREE

Symbols and abbreviations:
[:]= -- for assignment of variables
See LET below
= lists as :=
eg., a=7 lists as a:=7
b$="xyz" lists as b$:="xyz"
; for PRINT. Lists as PRINT ; [<string>]
* for OF 10 DIM A$ * 30 lists as 10 DIM A$ OF 30
:+ for add number to current value eg., a:+6 is equivalent to a:=a+6
:- for subtract number eg., a:-6 is equivalent to a:=a-6
// -- allows comments in a program // [<anything>]
REM accepted. Lists as // REM [<anything>]
! (pling)accepted. Lists as // ! [<anything>]
------
ABS -- gives the absolute value ABS(<numeric expression>)
AND -- logical AND <expression> AND <expression>
APPEND -- start at end of sequential disk file OPEN [FILE]<file#>, "<filename>",APPEND
ATN -- arctangent in radians ATN(<numeric expression>)
AUTO -- automatic line numbering AUTO [<start line>][,<increment>] Default is 10,10
BASIC -- back into BASIC mode BASIC
CASE -- multiple choice decisions CASE <control expression> [OF]
CAT -- gives disk directory CAT
CHAIN -- load & run program on disk CHAIN "<filename>"
CHR -- gives that numbers character CHR[$](<numeric expression>) $ lists if left out
CLOSE -- closes files. Defaults to all files CLOSE [[FILE] <filenum>] CLOSED -- all proc/func variables local PROC <procname>[(params)] [CLOSED] FUNC <funcname>[(params)] [CLOSED]
CON -- continue program execution CON
COS -- cosine in radians COS(<numeric expression>)
DATA -- provides data for a READ DATA <value>[,<value>][,...]
DEL -- deletes lines DEL <range>
DELETE -- deletes a file from disk DELETE "0:<filename>" N.B. Drive 0 (8) only.
DIM -- allocates string & array space DIM <string var> OF <max no of chars> DIM <str array>(<index>) OF <max chars> DIM <array name>(<array index>) where <array index> is [<low>:]<high>[,[<low>:]<high>,...] and <low>,<high> can be negative and <low> defaults to 1
DIV -- division with integer answer <dividend> DIV <divisor>
DO -- do the following statements DO <statements>
EDIT -- list lines without indentations EDIT [<range>]
ELIF -- short for ELSE IF condition ELIF <expression> [THEN]
ELSE -- IF struc alternative statements ELSE
END -- halt program execution END Optional.
ENDCASE -- end of CASE structure ENDCASE
ENDFOR -- end of FOR structure ENDFOR [<control variable>] NEXT -- accepted - lists as ENDFOR NEXT [<control variable>]
ENDFUNC -- end of function ENDFUNC [<function name>]
ENDIF -- end of IF structure ENDIF
ENDPROC -- end of procedure ENDPROC [<procedure name>]
ENDWHILE -- end of WHILE structure ENDWHILE
ENTER -- merge program segment stored using LIST Advise tag .L ENTER "<filename>" from disk ENTER "<filename>",1 from cassette Always NEW first if .L file is to be loaded without merging.
EOD -- End Of Data flag EOD
EOF -- End Of File flag EOF(<filenum>)
EXEC -- execute a procedure [EXEC] <name>[(<actual param list>)]
EXP -- natural log e to n EXP(<numeric expression>)
FALSE -- predefined value = 0 FALSE
FILE -- specifies that a file is used INPUT FILE <file#>[,<rec#>]: <var list> PRINT FILE <file#>[,<rec#>]: <var list> READ FILE <file#>[,<rec#>]: <var list> WRITE FILE <file#>[,<rec#>]: <var list> OPEN [FILE] <file#>,"<filename>",<type> CLOSE [[FILE] <file#>]
FOR -- start of FOR loop structure FOR <var>=<st> TO <e> [STEP <stp>] [DO]
FUNC -- start of a multiline function FUNC <name>[(<parm>)] FUNC <name>[(<parm>)] [CLOSED]
GOTO -- go to line with this name GOTO <label name>
IF -- start of conditional IF structure IF <condition> [THEN] IF <condition> THEN <statement>
IN -- locate string1 position in string2 <string1> IN <string2>
INPUT -- input from keyboard or file INPUT [<prompt>:] <var list> INPUT FILE <file#>[,<rec#>]:<var list>
INT -- nearest integer less than or equal INT(<numeric expression>)
KEY$ -- scans keyboard no key gives CHR$(0) KEY$
LABEL -- assigns label name to line [LABEL]<label name>[:] if LABEL left out, colon must be used
LEN -- gives the length of string LEN(<string expression>)
LET -- assign value to variable let [<variable>:=<expression>] let is optional
LINEFEED -- enables or disables linefeeds to printer LINEFEED+ adds a linefeed(CHR$(10)) when a carriage return (CHR$(13)) is sent to printer. Used when a Êprinter does not Êautomatically linefeed LINEFEED- disables(default)
LIST -- list program in memory to screen in formatted form LIST [<range>] LIST [<range>] "<filename>" to disk Advise tagging filename '.L' LIST [<range>] "<filename>",1 to cassette To list to a printer, SELECT "LP:" first, then LIST [<range>] POKE 26131,7 lower case POKE 26131,0 upper case(default) Poke should be executed before printer is selected.
LOAD -- Load a program file into memory LOAD "<filename>" Êfrom disk LOAD "<filename>",1 from cassette Traditional method- see ENTER and LIST.
LOG -- natural logarithm of n LOG(<numeric expression>)
MOD -- division remainder (modulo) <dividend> MOD <divisor>
NEW -- clears program from memory NEW
NOT -- logical NOT NOT <condition>
NULL -- does nothing (no op) NULL
OF -- part of DIM or CASE structure CASE <expression> [OF] DIM <stringvar> OF <max no of chars> DIM <stringarray>(index) OF <max chars>
OPEN -- open a file to disk. OPEN [FILE] <file#>,"<filename>",<type> See UNIT for how to open files to other devices
OR -- logical OR <condition> OR <condition>
ORD -- ASCII value of char ORD(<string expression>)
OTHERWISE -- default for CASE OTHERWISE
OUTPUT -- select output location SELECT [OUTPUT] "<type>" <type>= LP: for printer, DS: for screen
PASS -- pass string to disk command channel, drive 0 (8) only PASS "<disk command>" Format disc- "N0:<DISC NAME>,<ID>" Clear Direc- "N0:<DISC NAME>" Rename- "R0:<NEWNAME>=<OLD NAME>" Scratch- "S0:<FILE NAME>" Initialize- "I0" Validate- "V0"
PEEK -- look at memory PEEK(<memory address>)
POKE -- change memory location POKE <memory address>,<contents>
PRINT -- prints items to screen/printer/file PRINT [FILE <filenum>:] [<items>] PRINT [FILE <fil#>:] USING <fmt>:<vars> (RANDOM file use:[FILE <fil#>,<rec#>:])
PROC -- start of multiline procedure PROC <nam>[(<parm>)] PROC <nam>[(<parm>)] [CLOSED]
RANDOM -- random access disk file OPEN FILE <fil#>,"<name>",RANDOM <len>
READ -- read data from DATA line or file READ <var list> READ FILE <file#>[,<rec#>]: <var list> OPEN [FILE] <filenum>, "<filename>",READ
REF -- variable used in reference in procedure header to transfer values INTO and OUT OF a procedure REF <var>
REM -- see symbols and abbreviations list above
RENUM -- renumber program RENUM [<target start>][,<increment>] Beware! Line number range 0001 to 9999.
REPEAT -- start of REPEAT structure REPEAT
RESTORE -- reuse DATA with READ RESTORE
RETURN -- Assigns a value to a FUNCtion and returns control to calling statement RETURN <numeric expression>
RND -- random number RND(<num>) decimal number between 0 and 1 RND(<start num>,<end num>) integer in range given
RUN -- run program now in memory NOT a statement, ie., direct mode only RUN
SAVE -- record program SAVE "<filename>" on disk SAVE "<filename>",1 on cassette Traditional method- see LIST and ENTER.
SELECT -- choose output location SELECT [OUTPUT] "<type>" <type>= DS: for screen, LP: for printer
SETEXEC -- enables or disables the auto-inclusion of EXEC (execute) in front of PROC calls in listing. SETEXEC+ enables SETEXEC- disables(default)
SETMSG -- enables or disables the input of error messages from disc file. SETMSG+ enables(default) SETMSG- disables. Error number only, disc drive not activated
SGN -- -1 if negative, 0 if 0, 1 if positive SGN(<numeric expression>)
SIN -- gives sine in radians SIN(<numeric expression>)
SIZE -- memory usage (free memory) SIZE
SQR -- gives square root SQR(<numeric expression>)
STATUS -- status of disk channel STATUS equivalent to PRINT STATUS$ STATUS$ String var of disk status
STEP -- increment FOR loop variable by this amount STEP <numeric expression>
STOP -- halt program execution STOP
SYS -- give control to machine code SYS(<memory address>)
TAB -- print spaces up to specified column TAB(<column number>)
TAN -- gives tangent in radians TAN(<numeric expression>)
THEN -- part of IF structure THEN
TO -- increment FOR variable start TO end <start num> TO <end num>
TRAP -- control STOP key in conjunction with: ESC -- system variable TRAP ESC+ pressing the STOP key will stop the program. The value of ESC will always be FALSE (0) TRAP ESC- pressing the STOP key will NOT stop the program. The value of ESC is TRUE (1) when the STOP key is pressed. The value of ESC is FALSE (0) when the STOP is released
TRUE -- predefined value of 1 TRUE
UNIT -- specify unit (device) OPEN FILE <#>,"<n>",UNIT <#>[,<sa>],<t>
UNTIL -- end of REPEAT loop UNTIL <expression>
USING -- formatted output PRINT USING "<format>": <var list> <format> is a string expression where # reserves a digit place . fixes the decimal point - is a floating minus sign other char prints without change
WHEN -- choice in CASE structure WHEN <list of values>
WHILE -- start of WHILE structure WHILE <expression> [DO] [<statement>]
WRITE -- write to a file WRITE FILE <file#>[,<rec#>]: <var list> OPEN [FILE] <file#>, "<filename>",WRITE
ZONE -- tab increment
ZONE <tab interval>

SCREEN AND COLOUR CONTROL
BACKGROUND -- set screen background colour Will have no effect on HIRES screen until CLEAR command given. BACKGROUND(<colour number>)
BORDER -- set the screen border colour BORDER(<colour number>)
CLEAR -- clear total HIRES screen and set HIRES screen colours to current values of pencolor and background. CLEAR
FRAME -- set up a screen window for use with other commands (HOME) FRAME <left>,<right>,<bottom>,<top> Point 0,0 is bottom left of screen and the default is 0,319,0,199
FULLSCREEN -- display full HIRES screen without text window. Any text on display remains as it has been plotted to the screen FULLSCREEN
PENCOLOR -- sets the foreground colour. Will have no effect on the HIRES screen until the CLEAR command is given. PENCOLOR(<colour number>) SETGRAPHIC -- display HIRES screen and default to normal or multicolour depending on last used. Ie, display previous HIRES screen if it exists. This command CANNOT be given before either SETGRAPHIC(0) or SETGRAPHIC(1) has been given SETGRAPHIC SETGRAPHIC(0) -- display HIRES screen with visible turtle of size 10 and pendown. Colours will be taken from current values of background and pencolor. The top two lines form a scrolling window onto the text screen. This enables commands being typed to be viewed at the same time as the HIRES screen.
SETGRAPHIC(0) SETGRAPHIC(1) -- display multicolour mode
HIRES screen without window onto the text screen
SETGRAPHIC(1) SETTEXT -- turn on text screen SETTEXT
SPLITSCREEN -- re-enable the window on the text screen
SPLITSCREEN ÊHIGH RES and TURTLE graphics

BACK -- move turtle backwards, drawing if pendown BACK(<length>)
DRAWTO -- move turtle to given position drawing if pendown (as SETXY)
DRAWTO <x coordinate>,<y coordinate>
FILL -- fill bounded area around given point with current colour
FILL <x coordinate>,<y coordinate>
FORWARD -- move turtle forward, drawing if pendown FORWARD(<length>)
GETCOLOR -- returns colour number of HIRES screen pixel
GETCOLOR <x coodinate>,<y coordinate> If ON = foreground colour If OFF = background colour If -1 = x coordinate or y coordinate or both are off-screen
HIDETURTLE -- make the turtle invisible. Still draws if pendown
HIDETURTLE HOME -- put turtle at centre of frame. Does NOT draw even if pendown
HOME LEFT -- rotate turtle anticlockwise
LEFT(<degrees>) Negative degrees reverse rotation
MOVETO -- move turtle to point without drawing line even if pendown MOVETO <x coordinate>,<y coordinate>
PENDOWN -- puts pen down so turtle draws lines when it moves
PENDOWN PENUP -- pick up pen so turtle does not draw lines when it moves
PENUP PLOT -- plot a point in current color
PLOT <x coordinate>,<y coordinate>
PLOTTEXT -- print text on HIRES screen starting at character position which INCLUDES given point
PLOTTEXT <x coord>,<ycoord>,"<text$>"
RIGHT -- rotate turtle clockwise
RIGHT(<degrees>) Negative degrees reverse rotation
SETHEADING -- set turtle to point in given direction. Degrees measured clockwise with North as 0
SETHEADING(<degrees>)
SETXY -- move turtle to given position drawing if pendown
SETXY <x coordinate>,<y coordinate>
SHOWTURTLE -- make turtle visible
SHOWTURTLE TURTLESIZE -- set turtle size (0 to 10)
TURTLESIZE(<size>)
SPRITE CONTROL
--------------
DATACOLLISION -- returns a value of TRUE if the given sprite has collided with data. The bit in the data collision register for the given sprite will be reset if <flag> is TRUE. Otherwise the bit remains set
DATACOLLISION <sprite#>,<flag>
DEFINE -- set up sprite image for later call up by def#
DEFINE <def#>,"<64 byte def$>" Def# 0 is the turtle and the 64th byte of the def$ is used to indicate regular or multicolour sprite. CHR$(0) means sprite is regular. Any other means multicolour.
HIDESPRITE -- turn off specified sprite
HIDESPRITE(<sprite#>)
IDENTIFY -- assign an image to a sprite and turn the sprite on
IDENTIFY <sprite#>,<def#> (Note: sprite 7 is used for the turtle)
PRIORITY -- set priority of given sprite with respect to background. A boolean value of TRUE gives sprite priority. A value of FALSE gives background priority
PRIORITY <sprite#>,<boolean value>
SPRITEBACK -- set 2 multicolour sprite colours
SPRITEBACK <colour1>,<colour2>
SPRITECOLLISION -- returns a value of TRUE if the given sprite has collided with another sprite. The bit in the sprite collision register which corresponds with the given sprite will be reset if <flag> is TRUE. Otherwise the bit remains set
SPRITECOLLISION <sprite#>,<flag>
SPRITECOLOR -- set colour of sprite
SPRITECOLOR <sprite#>,<colour number>
SPRITEPOS -- position sprite at x,y location
SPRITEPOS <sprt#>,<x coord>,<y coord>
SPRITESIZE -- Expand given sprite in appropriate direction if x-xpand or y-xpand <> 0
SPRITESIZE <spr#>,<x-xpand?>, <y-xpand?>
RUN STOP-RESTORE

If your program should hang up for any reason press 'RUN STOP' and 'RESTORE' together. This should return you to COMAL. If you had been executing ANY file handling command when the hangup occurred then give the command CLOSE.

COMMODORE 64 COMAL COLOURS LIST
COLOUR NUM NAME CHR$
0 BLACK144
1 WHITE 5
2 RED 28
3 CYAN 159
4 PURPLE 156
5 GREEN30
6 BLUE 31
7 YELLOW 158
8ORANGE 129
9 BROWN 149
10 LT RED 150
11 DK GREY 151
12 MD GREY 152
13 LT GREEN 153
14 LT BLUE 154
15 LT GREY 155

The information given in this file originated from the US COMAL USERS GROUP. It has been debugged, updated and anglicised by Brian Grainger of ICPUG If you find any errors please let me know:
Brian Grainger Rev. 3 August 1984

Revised and updated by B.C.R.Burford following consultation with B.Grainger. 08/12/99.
More small revisions 16/02/00.