[net.micro] COMAL: a better BASIC for your 64

porter@inuxd.UUCP (J Porter) (03/06/84)

========================================================================

For those of you who have been missing out on the lastest free
operating system for your C64, take note.  This is probably of
general interest anyways.  COMAL is like SIMON'S BASIC only
better (in most respects), and you can't beat the price, because
it's in the public domain.  The following is a short description 
followed by a complete command summary.  Every 64 owner ought
to have this one.

Jeff Porter  (inuxd!porter)
AT&T Consumer Products
Indianapolis

=======================================================================

       COMAL FOR THE COMMODORE 64

       Welcome to COMAL, the language designed to replace BASIC.

       This information is as of November  25, 1983 and is subject
       to change.

       COMAL TODAY newsletter  is  the  source for up to date
       information about COMAL, as  well  as  many  helpful  hints
       and tutorial articles. Contributors to this newsletter
       include  Borge  Christensen (founder  of   COMAL),
       UniComal   Aps (Authors of all CBM COMAL systems), and Len
       Lindsay (author of COMAL HANDBOOK).  It is  published  by
       the  COMAL  Users Group (USA) for $14.95.

       The COMAL HANDBOOK is  meant  to  be  a complete reference
       for all versions  of CBM COMAL. This book  is  published  by
       Reston Publishing (1-800-336-0338).  It retails  for  about
       $18.95   and   is available  through  most   large   book
       stores, such as B. Daltons, or from the COMAL Users Group
       (USA).

       The CAPTAIN COMAL series  of  book/disk packages are meant
       to be  tutorials  to modular  programming  with  COMAL.  The
       first, CAPTAIN COMAL GETS ORGANIZED, is available from the
       COMAL  Users  Group for $19.95 (including book and disk).

       CBM COMAL version  0.14  on  this  disk includes added
       graphics,  turtle,  and sprite commands. Also the keywords
       KEY$ and PRINT USING are included. Otherwise COMAL HANDBOOK
       first  edition  can  be used as  reference  for  version
       0.14.  (Whenever  the  book  mentions  version 0.12, just
       replace it with  0.14).  The only difference  is  in
       selecting  the output  location.  Version  0.12   used
       SELECT OUTPUT "LP"  and  SELECT  OUTPUT "DS". Version 0.14
       uses  SELECT  OUTPUT "LP:"  and  SELECT  OUTPUT  "DS:".  The
       colon is now required, allowing  it  to be compatible with
       the  advanced  file handling system employed by the version
       2.00 cartridge due for  release  Spring 1984.

       The  graphics,   sprite,   and   turtle commands will be
       documented by the book COMMODORE 64 GRAPHICS  AND  SOUND
       WITH COMAL  to  be   published   by   Reston Publishing
       Summer 1984. A brief summary of  all  these   added
       commands   and statements are  included  in  the  data file
       on this disk called  INSTRUCTIONS.  Run  the  program
       SEE'INSTRUCTIONS  to read about them. It lists all the words
       with their correct syntax. [ed: shown below]

       There are two ways to store programs on the disk, and two
       corresponding ways to retrieve them:

       SAVE "NAME" This saves the program currently in the computer
       onto disk  as  a  binary  file with  the  name  you
       specified  inside quotes. It can be retrieved  via  LOAD,
       but only with an exact same  CBM  COMAL version.

       LIST "NAME.L" This  stores the program  currently  in the
       computer onto disk as an ASCII file with  the  name  you
       specified  inside quotes (we suggest  that  you  end  the
       file name with a .L to remind you later that the file is a
       LIST file). The file is a bit larger than the  same  program
       stored via SAVE.  However,  this  ASCII file has many
       additional uses.  It  can be retrieved by ANY CBM COMAL
       version.  It can be merged with  another  program at a later
       time.  It  can  be  read  by another  program   using
       INPUT   FILE statements.

       LOAD "NAME" This will  erase  the  current  program first,
       then will retrieve  the  program stored  on  disk  with  the
       name   you specified inside quotes.  Then  to  run the
       program issue the RUN command.

       CHAIN "NAME" This is similar to  the  LOAD  command, but
       the  program  will  LOAD  and  RUN automatically.

       ENTER "NAME.L" This will merge the program or  program
       segment  from   disk   with   the   one currently in the
       computer (remember the suggested .L at the  end  of  the
       file name).  Line  numbers  are  significant during this
       process in version 0.14. If a line is  ENTERed  with  a
       same  line number as one already existing  in  the computer,
       the previous line is  deleted and the new line ENTERed
       replaces  it.  To avoid this problem, simply  RENUMber a
       program or program  segment  to  high line number before
       LISTing it  to  disk (ie, RENUM 8000). To retrieve  a  whole
       program, issue the NEW  command  first, then the ENTER
       command.

       To list the program  currently  in  the computer to the
       printer: SELECT OUTPUT "LP:" LIST

       To see what is on your disk: CAT

       SPECIAL NOTE: Due to a peculiarity in the C64  serial IEEE
       to disk  and  printer  you  cannot select output to printer
       and then do  a CAT. But the COMAL  USERS  GROUP  (USA) has
       provided you a way to print a  disk directory on the printer
       bypassing this problem.   Try   the   program   called
       "PRINT'DIRECTORY".

       NOTE ON OLD COMAL 0.12 PROGRAMS Programs written for version
       0.12  will run on version 0.14. But LIST  them  to disk from
       version 0.12 and  ENTER  them into 0.14. The LOAD/SAVE files
       are  not completly compatible and could lock out your
       system.

       Do NOT try to LOAD a BASIC program file into COMAL. COMAL
       gets upset.

       ====================================== 
       COMAL Users Group
       5501 Groveland Terrace 
       Madison, WI  53716

       (608) 222-4432

       Include $2 Shipping/Handling with every order. Or send a
       self addressed stamped envelope for more  information.
       Prices listed are subject to change.

	
	COMAL KEYWORDS: (version 0.14)
	
	// -- allows comments in a program
	//[<anything>]
	
	ABS -- gives the absolute value
	ABS(<numeric expression>)
	
	AND -- logical AND
	<expression> AND <expression>
	
	APPEND -- start at end of seq file
	OPEN [FILE] <file#>,<filename>,APPEND
	
	ATN -- arctangent in radians
	ATN(<numeric expression>)
	
	AUTO -- automatic line numbering
	AUTO [<start line>][,<increment>]
	
	BASIC -- back into BASIC mode
	BASIC
	
	CASE -- multiple choice decisions
	CASE <control expression> [OF]
	
	CAT -- gives disk directory
	CAT [<drive number>]
	
	CHAIN -- load & run program on disk
	CHAIN <filename>
	
	CHR$ -- gives that numbers character
	CHR$(<numeric expression>)
	
	CLOSE -- closes 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 <filename>
	
	DIM -- allocates string & array space
	DIM <string var> OF <max char>
	DIM <str array>(<index>) OF <max char>
	DIM <array name>(<array index>)
	
	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
	
	ENDCASE -- end of CASE structure
	ENDCASE
	
	ENDFOR -- end of FOR structure
	ENDFOR [<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 from disk
	ENTER <filename>
	
	EOD -- End Of Data flag
	EOD
	
	EOF -- End Of File flag
	EOF(<filenum>)
	
	ESC -- stop key pressed flag
	ESC
	TRAP ESC<type>
	
	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#>]: <val 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>)] [EXTERNAL <name>]
	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 (not PET 0.14)
	KEY$
	
	LABEL -- assigns label name to line
	<label name>:
	
	LEN -- gives the length of string
	LEN(<string expression>)
	
	LET -- assign value to variable
	:=
	
	LIST -- list program
	LIST [<range>] [<filename>]
	
	LOAD -- load a program from disk
	LOAD <filename>
	
	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 char>
	DIM <stringarray>(index) OF <max char>
	
	OPEN -- open a file
	OPEN [FILE] <file#>,<filename>[,<type>]
	
	OR -- logical OR
	<condition> OR <condition>
	
	ORD -- integer representing the char
	ORD(<string expression>)
	
	OTHERWISE -- default for CASE
	OTHERWISE
	
	OUTPUT -- select output location
	SELECT [OUTPUT] <type>
	
	PASS -pass string to disk command chanl
	PASS <disk command>
	
	PEEK -- look at memory
	PEEK(<memory address>)
	
	POKE -- change memory location
	POKE <memory address>,<contents>
	
	PRINT -prints items to scrn/printr/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>)] [EXTERNAL <name>]
	PROC <nam>[(<parm>)] [CLOSED]
	
	RANDOM -- random access disk file
	OPEN FILE <fil#>,<name>,RANDOM <recln>
	
	READ -read data from DATA line or file
	READ <var list>
	READ FILE <file#>[,<rec#>]: <var list>
	OPEN [FILE] <filenum>,<filename>,READ
	
	REF -parm var used in reference in proc
	REF <var>
	
	RENUM -- renumber program
	RENUM [<targetstart>][,<increment>]
	
	REPEAT -- start of REPEAT structure
	REPEAT
	
	RESTORE -- reuse DATA with READ
	RESTORE
	
	RND -- random number
	RND(<num>)
	RND(<start num>:<end num>)
	
	RUN -- run program now in memory
	RUN
	
	SAVE -- record program on disk
	SAVE <filename>
	
	SELECT -- choose output location
	SELECT [OUTPUT] <type>
	
	SGN -- -1 if neg, 0 if 0, 1 if pos
	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$
	
	STEP -incremnt FOR loop var this amount
	STEP <numeric expression>
	
	STOP -- halt program execution
	STOP
	
	SYS -give control to assembly language
	SYS(<memory address>)
	
	TAB -- print spaces up to specified col
	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 -- disable stop key
	TRAP ESC<type>
	
	TRUE -- predefined value of 1
	TRUE
	
	UNIT -- specify unit (device)
	OPEN FILE <#>,<n>,UNIT
	<dv>[,<sc>][,<tp>]
	
	UNTIL -- end of REPEAT loop
	UNTIL <expression>
	
	USING --formatted output (not PET 0.14)
	PRINT USING <format>: <var list>
	
	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] <filenum>,<filename>,WRITE
	
	
	ZONE -- tab increment
	ZONE <tab interval>
	ZONE
	
	TURTLE GRAPHICS CHART    CBM COMAL
	-----------------------  ---------
	TURTLE CONTROL:
	Move forward length      FORWARD
	Move backward length     BACK
	Home turtle              HOME
	Turn turtle left         LEFT
	Turn turtle right        RIGHT
	Move to a point          SETXY
	Turn to specific heading SETHEADING
	Make turtle visible      SHOWTURTLE
	Make turtle invisible    HIDETURTLE
	Pen up off paper         PENUP
	Pen down on paper        PENDOWN
	Set pen color            PENCOLOR
	Number of colors         16
	Set size of turtle       TURTLESIZE
	Plot a point             PLOT
	Print text in graphics   PLOTTEXT
	
	SCREEN AND COLOR CONTROL:
	Set screen window        FRAME
	Clear graphics screen    CLEAR
	Set to graphics mode     SETGRAPHIC
	Set to text screen       SETTEXT
	Set background color     BACKGROUND
	Set border color         BORDER
	Fill in an area          FILL
	Full screen mode         FULLSCREEN
	Split screen mode        SPLITSCREEN
	
	FUNCTION KEYS RESULTS:
	F1                       TEXT SCREEN
	F3                       SPLITSCREEN
	F5                       FULLSCREEN
	
	COMMODORE 64 COMAL COLORS LIST
	
	COL  COLOR  CHR$ !  COL  COLOR     CHR$
	NUM  NAME        !  NUM  NAME
	---  -----  ---  !  ---  -------   ---
	 0   BLACK  144  !   8   ORANGE    129
	 1   WHITE  5    !   9   BROWN     149
	 2   RED    28   !  10   LT RED    150
	 3   CYAN   159  !  11   DK GREY   151
	 4   PURPL  156  !  12   MD GREY   152
	 5   GREEN  30   !  13   LT GREEN  153
	 6   BLUE   31   !  14   LT BLUE   154
	 7   YELLW  158  !  15   LT GREY   155
	
	SPRITES (version 0.14)
	
	DATACOLLISION -test collision with data
	DATACOLLISION <sprt#>,<reset cols flg?>
	
	DEFINE -set up sprite image for later
	DEFINE <sprt definitn#>,<64 byte def$>
	
	HIDESPRITE -- turn off specified sprite
	HIDESPRITE <sprite number>
	
	IDENTIFY -- assign a sprite an image
	IDENTIFY <sprite number>,<definition #>
	(note: sprite 7 is used for the turtle)
	
	PRIORITY -does data priority over sprt
	PRIORITY <sprite #>,<data priority?>
	
	SPRITEBACK -set 2 multicolor sprt colrs
	SPRITEBACK <color1>,<color2>
	
	SHOWSPRITE -- turn on specified sprite
	SHOWSPRITE <sprite number>
	
	SPRITECOLLISION -test sprite collision
	SPRITECOLLISION <spr#>,<reset col flg?>
	
	SPRITECOLOR -- set color of sprite
	SPRITECOLOR <sprite #>,<color number>
	
	SPRITEPOS -- position sprite at x,y loc
	SPRITEPOS <sprt#>,<x coord>,<y coord>
	
	SPRITESIZE -sprite size (expand or not)
	SPRITESIZE <spr#>,<y xpand?>,<x xpand?>
	
	HIGH RES and TURTLE graphics COMAL 0.14
	
	BACK -- move turtle backwards
	BACK <length>
	
	BACKGROUND -set screen background color
	BACKGROUND <color number>
	
	BORDER -- set the screen border color
	BORDER <color number>
	
	CLEAR -clear graphics screen (in frame)
	CLEARSCREEN
	
	DRAWTO -- draw line from current point
	DRAWTO <x coordinate>,<y coordinate>
	
	FILL -- fill in area with current color
	FILL <x coordinate>,<y coordinate>
	
	FORWARD -- move turtle forward
	FORWARD <length>
	
	FRAME -- set up a screen window
	FRAME <x0>,<x1>,<y0>,<y1>
	
	FULLSCREEN -- fullscreen graphics (f5)
	FULLSCREEN
	
	HIDETURTLE -- make the turtle invisible
	HIDETURTLE
	
	HOME -put turtle in its home position
	HOME
	
	LEFT -- turn turtle left
	LEFT <degrees>
	
	MOVETO -move to point without line
	MOVETO <x coordinate>,<y coordinate>
	
	PENCOLOR -set current turtle pen color
	PENCOLOR <color number>
	
	PENDOWN -put pen down-turtle draws line
	PENDOWN
	
	PENUP -pick up pen-no turtle lines
	PENUP
	
	PLOT -- plot a point in current color
	PLOT <x coordinate>,<y coordinate>
	
	PLOTTEXT -print text on graphics screen
	PLOTTEXT <x coord>,<y coord>,<text$>
	
	RIGHT -- turn turtle right
	RIGHT <degrees>
	
	SETGRAPHIC -- turn on graphics screen
	SETGRAPHIC [<type>]
	
	SETHEADING -- set turtle heading
	SETHEADING <degree>
	
	SETTEXT -- turn on text screen (f1)
	SETTEXT
	
	SETXY -- set turtle x and y coordinates
	SETXY <x coordinate>,<y coordinate>
	
	SHOWTURTLE -- make turtle visible
	SHOWTURTLE
	
	SPLITSCREEN -2 line text above graphics
	SPLITSCREEN
	
	TURTLESIZE -- set turtle size (0 to 10)
	TURTLESIZE <size>