Users Guide |
At the console prompt (e.g. C> ) type the
following:
CCBASIC
And press the enter key.
Note that the file ccbasic.exe must be in the current directory or in a directory specified in the PATH environment variable.
Click the icon for the Cheesecake BASIC interpreter.
After Cheesecake BASIC initializes, it will display the following prompt:
READY
That means Cheesecake BASIC is ready to take your commands.
BRK line |
Sets a breakpoint at the specified line number |
BYE |
Exits the interpreter. |
CBRK [line] |
Clears the specified breakpoint. If no line number is specified, all breakpoints in the program are cleared. |
CONT |
Resumes a program after a STOP statement is executed or a breakpoint is hit. |
LIST [line [-line]] |
Lists the program. |
LOAD "path" |
Loads a program. |
NEW |
Re-initializes the interpreter. |
RENUM [increment] |
Renumbers the program lines. If no increment is specified, the default is 10. |
RUN |
Runs the program. |
SAVE "path" |
Saves the program under the given name |
TRACE {ON | OFF} |
Sets trace mode on or off. |
Programs are loaded into Cheesecake BASIC with the LOAD command. The syntax of the LOAD command is:
LOAD "name-of-program"
The name of the program must include any extensions (e.g. .BAS) and must be inside double quotes. The program must be an ASCII file containing BASIC program lines, BASIC statements, or interpreter commands.
The current program can be saved to a file using the SAVE command. The syntax of the SAVE command is:
SAVE "name-of-program"
The name of the program must include any extensions (e.g. .BAS) - Cheesecake BASIC will not add any default extension - and it must be inside double quotes. Files are saved in text (ASCII) form.
Cheesecake BASIC has a line-based editor similar to other BASIC interpreters.
Using the Cheesecake BASIC editor
The Cheesecake BASIC editor is a line-based editor. All lines must begin with a line number. The line number determines the position of the line within the file.
To add a line |
Enter the line number followed by the BASIC line. e.g: 50 PRINT "Hello world"
|
To replace a line |
Enter the line number followed by the BASIC line. If there is a line with the same line number, it will be replaced. If there is no line with the same line number, it will be added (see above). e.g. 50 PRINT "Good bye"
|
To delete a line |
Enter a line number. If there is a line with the same line number, it will be deleted. If there is no line with the same line number, no action will be taken. e.g. 50
|
To list lines |
Use the LIST command to list line ranges. E.g.
|
To renumber lines |
Use the RENUM command. The syntax of the RENUM command is: |
The current program can be executed with the RUN command. The syntax of the RUN command is:
RUN
This will run the program until the program executes an END or STOP statement, an unhandled error is encountered, or a breakpoint it hit.
Cheesecake BASIC provides the following debugging support:
TRACE
When executing in trace mode, the interpreter displays each source line before the line statements are executed. Trace mode is turned on or off using the TRACE statement, with the following syntax:
TRACE {ON | OFF}
After a TRACE ON statement, each source line is displayed before being executed. This continues until the program terminates or until a TRACE OFF statement is executed. If you want to trace the entire program, you can execute a TRACE ON before running the program. If you want to trace only a portion of a program, you can enclose the program portion between TRACE ON and TRACE OFF statements.
STOP
STOP statements can be placed in the program at places where you want the interpreter to stop program execution. When a STOP statement is executed, the interpreter stops executing the program. The user can then display the value of variables (using PRINT statements), change the value of variables (using LET statements) etc. To resume a stopped program, use the CONT command.
Breakpoints
Breakpoints can be used to stop execution of a program at a specific line without needing to add STOP statements to the program. When execution reaches that line, the interpreter stops executing the program. The user can then use immediate BASIC statements to display the value of variables, change variables etc. The program can resume execution using the CONT command.
Setting breakpoints:
To set a breakpoint, use the BRK command, with the following syntax:
BRK <Line number>
Clearing breakpoints:
To clear a breakpoint, use the CBRK command, with the following syntax:
CBRK [Line number]
If no line number is specified, CBRK will clear ALL the breakpoints in the program.
To continue execution of a program after a breakpoint is hit or a STOP statement is executed:
To continue execution of a program, use the CONT command, with the following syntax:
CONT
The CONT command can also be used after the program executes a STOP statement.
BASIC statements that are not part of a program line (i.e. a line starting with a line number) are executed immediately by the interpreter.
E.g.
READY
DIM A$(2)
READY
A$(2) = "Hello world!"
READY
PRINT A$(2)
Hello world!
READY
To exit the interpreter use the BYE command. The syntax of the BYE command is:
BYE
Language Reference |
Cheesecake BASIC supports the following data types:
INTEGER |
16-bit signed integer |
|
SINGLE |
32-bit floating point |
|
STRING |
String. |
If an identifier does not include a type-specifier suffix, the default type is SINGLE.
You can control the default data type of variables and arrays based on the first character of their identifier, by using the DEFINT, DEFSNG, or DEFSTR statements.
All lines in a Cheesecake BASIC Program must be numbered. Line numbers must be between 1 and 32767.
Cheesecake BASIC allows statements to be separated by colons. E.g.:
10 BEEP : PRINT : PRINT "Hello World" : PRINT : END
Note the following exception:
DATA statements must be the ONLY statement in their line. In the following example, line 10 is a valid Cheesecake BASIC line, but lines 20 and 30 are not:
10 DATA a, b, c
20 PRINT : DATA a, b, c
30 DATA a, b, c ' This is the data
Following is the list of Cheesecake BASIC statements:
BEEP |
||
CHDIR "path" |
||
CLOSE [#]filenumber |
||
CLS |
||
COLOR fg [,bg] |
||
DATA constant [,constant]* |
||
DEF name(args) = expression |
||
DEFINT letter range [. letter range]* |
||
DEFSNG letter range [. letter range]* |
||
DEFSTR letter range [. letter range]* |
||
DIM arrayname(size [,size]*) [, arrayname(size [,size]*)]*
|
||
END |
||
ERROR errornumber |
||
EXIT [FOR | WHILE] |
||
FIELD #filenumber, integer as fieldname [,integer as fieldname]* |
||
FOR id=firstvalue TO lastvalue [STEP increment] |
||
GET #filenumber |
||
GOSUB linenumber |
||
GOTO linenumber |
||
IF exp THEN statements [ELSE statements] |
||
INPUT [#filenumber,] [prompt {,|;}] var [,var]* |
||
KEY(keynumber) {ON | OFF | STOP} |
||
KILL "path" |
||
[LET | LSET | RSET] var = exp |
||
LINE INPUT [#filenumber,] [prompt {,|;}] var [,var]* |
||
LOCATE x, y |
||
NEXT [id] |
||
ON ERROR GOTO linenumber |
||
ON exp GOSUB linenumber [,linenumber]* |
||
ON exp GOTO linenumber [,linenumber]* |
||
ON KEY(keynumber) GOSUB linenumber |
||
ON TIMER(seconds) GOSUB linenumber |
||
OPEN filename [FOR {INPUT|OUTPUT|APPEND|RANDOM}] as #filenumber [LEN=length] |
||
PRINT [#filenumber,] print-list |
||
PUT #filenumber |
||
RANDOMIZE [exp] |
||
READ var [,var]* |
||
REM (or apostrophe) [comments] |
||
RESTORE [linenumber] |
||
RESUME [NEXT | linenumber] |
||
RETURN [linenumber] |
||
SEEK #filenumber, recordnumber |
||
SHELL "command" |
||
SLEEP seconds |
||
STOP |
||
TIMER {ON | OFF | STOP} |
||
WEND |
||
WHILE exp |
Cheesecake BASIC for DOS also supports the following statements:
CIRCLE [STEP] (x,y), radius [, color [,start, end [,aspect]]] |
DEF SEG[=value] |
DRAW string-expression |
LINE [STEP] [(x,y)] - [STEP] (x,y) [, [color][,B[F]]] |
OUT port-no, value |
PLAY string-expression |
POKE address, value |
PRESET [STEP] (x,y) [,color] |
PSET [STEP] (x,y) [,color] |
SCREEN [mode] [, [color] [, [apage] [, [vpage]]]] |
SOUND freq, duration |
VIEW [SCREEN] (x,y) - (x,y) [. [color [, [boundary]]] |
WINDOW [SCREEN] (x,y) - (x,y) |
ABS |
Returns the absolute value of a numeric expression. |
ASC |
Returns the ASCII code of the first character in a string. |
ATN |
Returns the arctangent of a numeric expression. |
CHR$ |
Converts an ASCII code into a one-character string. |
CINT |
Converts a numeric expression into an integer by rounding the
fractional part of the expression. |
COS |
Returns the cosine of a numeric expression. |
CURSORX |
Returns the horizontal position of the cursor. |
CURSORY |
Returns the vertical position of the cursor. |
CVI |
Converts a string containing an integer into an INTEGER. |
CVS |
Converts a string containing an single into an SINGLE. |
DATE$ |
Retrieves the system date. |
EOF |
Returns non-zero if the end of the file has been reached, zero
otherwise. |
ERL |
Returns the error line of the last error. |
ERR |
Returns the error code of the last error. |
ERT$ |
Returns the error text of the last error. |
EXP |
Returns the base e (2.7182..) raised to a power. |
FIX |
Truncates a number to an INTEGER. |
INKEY$ |
Reads a character from the keyboard. |
INSTR |
Returns the position of a substring within a string. |
INT |
Returns the largest integer less than or equal to a numeric
expression. |
LCASE$ |
Lowercases a string. |
LEFT$ |
Returns the leftmost n characters of a string. |
LEN |
Returns the length of a string. |
LOC |
Returns the current position within a file. |
LOF |
Returns the length of a file. |
LOG |
Returns the natural (base e) logarithm of a number. |
LTRIM$ |
Returns a string with leading spaces removed. |
MID$ |
Returns a portion of a string. |
MKI$ |
Converts an integer to a 2-byte string. |
MKS$ |
Converts a single to a 4-byte string. |
RIGHT$ |
Returns the rightmost n characters of a string. |
RND |
Return a random number between 0 and 1. |
RTRIM$ |
Returns a string with traling spaces removed. |
SEEK |
Returns the current position within a file. |
SGN |
Returns the sign of a number. |
SIN |
Returns the sine of a numeric expression. |
SPACE$ |
Returns a string consisting of n spaces. |
SQR |
Returns the square root of a number. |
STR$ |
Returns the string representation of a number. |
STRING$ |
Returns a string consisting of multiple copies of a character. |
TAB |
Used only in PRINT statements, moves the print head to the specified
column. |
TAN |
Returns the tangent of a numeric expression. |
TIME$ |
Retrieves the system time. |
TIMER |
Returns the number of seconds since midnight. |
UCASE$ |
Uppercases a string. |
VAL |
Converts a string to a number. |
Cheesecake BASIC for DOS also supports the following functions:
INP |
Reads a byte from an I/O Port. |
PEEK |
Returns the byte at the specified memory address. |
POINT |
Returns the color of a screen pixel. |
SCREEN |
Returns the ASCII code of the character at the specified screen
location. |