MCX Basic Help

Software development system


MCX BASIC is a dialect of the BASIC programming language. MCX BASIC is designed to follow GW-BASIC, which is one of the standard BASICs running on 16-bit computers. During the creation of MCX BASIC, a major effort was made to make the system as flexible and expandable as possible.

MCX BASIC development environment is very similar to that of the Dartmouth Time Sharing System associated with Dartmouth BASIC. It has a command line-based Integrated Development Environment (IDE) system; all program lines must be numbered, all non-numbered lines are considered to be commands in direct mode (i.e., to be executed immediately). The user interface is almost completely command line.

The original BASIC language was designed on May 1, 1964 by John Kemeny and Thomas Kurtz and implemented by a team of Dartmouth College students under their direction. The acronym BASIC comes from the name of an unpublished paper by Thomas Kurtz. BASIC was designed to allow students to write mainframe computer programs for the Dartmouth Time-Sharing System. It was intended specifically for less technical users who did not have or want the mathematical background previously expected. Being able to use a computer to support teaching and research was quite novel at the time.

The language was based on FORTRAN II, with some influences from ALGOL 60 and with additions to make it suitable for timesharing. Initially, BASIC concentrated on supporting straightforward mathematical work, with matrix arithmetic support from its initial implementation as a batch language, and character string functionality being added by 1965.

The designers of the language decided to make the compiler available free of charge so that the language would become widespread. (In the 1960s, software became a chargeable commodity; until then, it was provided without charge as a service with the very expensive computers, usually available only to lease.) They also made it available to high schools in the Hanover area, and put a considerable amount of effort into promoting the language. In the following years, as other dialects of BASIC appeared, Kemeny and Kurtz's original BASIC dialect became known as Dartmouth BASIC.

Operator ABS()

Syntax

ABS(x)

Description

Returns the absolute value of a variable

Examples
10 PRINT "The absolute value of 5 is ",ABS(5)
20 PRINT "The absolute value of -1.23 is ",ABS(-1.23)
 
RUN
The absolute value of 5 is 5
The absolute value of -1.23 is 1.23
Related to

INT

Operator ASC()

Syntax

ASC(x$)

Description

Returns the ASCII value of the first character in a string

Examples
10 PRINT "The ASCII value of B is ",ASC("B")
20 PRINT "The ASCII value of MCX is -1.23 is ",ASC("MCX")
 
RUN
The ASCII value of B is 66
The ASCII value of MCX is 77
Related to

CHR$,STRING$

Operator ATN()

Syntax

ATN(x)

Description

Returns the arctangent of a variable

Examples
10 PRINT "The arctangent of 1 is ",ATN(1)
20 PRINT "The arctangent of -1.23 is ",ATN(-1.23)
 
RUN
The arctangent of 1 is .78539816339745
The arctangent of -1.23 is .88817377437769
Related to

COS,SIN,TAN

Operator AUTO

Syntax

auto

Description

Starts automatic line numbering. The line number will start with 10, incrementing in steps of 10. To stop press 'ESC'.

Examples

auto

Related to

RENUM

Operator BEEP

Syntax

beep

Description

Simple 'beep' sound.

Examples

beep

Related to

Operator BIN$()

Syntax

BIN$(x)

Description

Returns a string with the binary representation of a (decimal) number

Examples
10 PRINT "The binary representation of 8 is ",BIN$(8)
20 PRINT "The binary representation of 127 is ",BIN$(127)
 
RUN
The binary representation of 8 is 1000
The binary representation of 127 is 11011

Related to

HEX$,OCT$

Operator CHR$()

Syntax

CHR$(x)

Description

Returns a string containing the ASCII character with the ASCII code of a variable.

Examples
10 PRINT "The character with ASCII code 67 is ",CHR$(67)
20 PRINT "I like ",CHR$(77),CHR$(67),CHR$(88)
 
RUN
The character with ASCII code 67 is B
I like MCX

Related to

ASC

Operator CINT()

Syntax

CINT(x)

Description

Returns the passed parameter rounded up.

Examples
10 PRINT "1.23 converted to integer is ",CINT(1.23)
20 PRINT "1.99 converted to integer is ",CINT(1.99)
 
RUN
1.23 converted to integer is 2
1.99 converted to integer is 2

Related to

INT,FIX

Operator CLEAR

Syntax

clear

Description

Sets all numeric variables to zero, all strings to null.

Examples

clear

Related to

Operator CLS

Syntax

cls

Description

Clears the screen.

Examples

cls

Related to

Operator COLOR foreground [,background]

Syntax

COLOR <foreground>[,<background>]

Description

Changes the color(s) to be used for the foreground and background.

Examples

COLOR 1,13

Related to

Operator COS()

Syntax

COS(x)

Description

Returns the cosine of a variable in radians.

Examples
10 PRINT "The cosine of a 45 degree angle is ",COS(45)
20 PRINT "The cosine of a 0 degree angle is ",COS(0)
 
RUN
The cosine of a 45 degree angle is .52532198881661
The cosine of a 0 degree angle is 1

Related to

ATN,SIN,TAN

Operator CSRLIN

Syntax

csrlin

Description

Returns the vertical coordinate of the cursor.

Examples
10 CLS
20 PRINT "Example of CSRLIN"
30 PRINT CSRLIN
 
RUN
Example of CSRLIN
1

Related to

POS

Operator DATA

Syntax

DATA <data>

Description

Store data in a program, to be read with the READ command

Examples
DATA 1,2,3,4,MCX," Forever! "

Related to

READ

Operator DATE

Syntax

date x$

Description

Reads the date to string variable.

Examples
DATA x$,a
Related to

TIME

Operator DELETE

Syntax

DELETE <line number>[-<end line number>]

Description

Erase part of an MCX-BASIC listing from memory.

Examples
10 PRINT "Haha! I am here to stay!"
20 PRINT "Oh no! I will be sent to oblivion!"
 
DELETE 20
RUN
Haha! I am here to stay!

Related to

Operator DIM

Syntax

dim <variable>(<size>)

Description

Specify the dimension of an array.

Examples
10 DIM A(20)
20 A(20)=2
30 PRINT "In row 20 of array A I stored the value ",A(20)
 
RUN
In row 20 of array A I stored the value 2
Related to

Operator END

Syntax

end

Description

Close all open files (if any) and end program execution.

Examples
10 PRINT "The end is nigh!"
20 END
30 PRINT "I shall not be executed"
 
RUN
The end is nigh!

Related to

Operator EXP()

Syntax

exp(x)

Description

Returns e (mathematical constant) to the power of x

Examples
10 PRINT "e to the power of 1 is ",EXP(1)
20 PRINT "e to the power of 0 is ",EXP(0)
 
RUN
e to the power of 1 is 2.7182818284588
e to the power of 0 is 1

Related to

Operator FIX()

Syntax

fix(x)

Description

Returns the integer part of a variable by truncating the numbers after the decimal point.

Examples
10 PRINT "FIX(1.23) results in ",FIX(1.23)
20 PRINT "FIX(-1.99) results in ",FIX(-1.99)
30 PRINT "FIX(-1.01) results in ",FIX(-1.01)
 
RUN
FIX(1.23) results in 1
FIX(-1.99) results in -1
FIX(-1.01) results in -1

Related to

INT,CINT

Operator FILES

Syntax

files

Description

Displays saved BASIC program.

Examples

files

Related to

Operator FOR...NEXT

Syntax

FOR <variable>=<start value> TO <end value> [STEP <increment>] ... NEXT

Description

Sets up a loop in order to repeat a block of commands until the counter variable has reached (or exceeded) the end value.

Examples
10 FOR x=1 TO 25 STEP 5
20 PRINT x
30 NEXT
 
RUN
1
6
11
16
21

Related to

Operator GOTO

Syntax

GOTO <line number>

Description

Jump to the specified line number and execute the commands from there.

Examples
10 GOTO 100
20 PRINT "Now it's my turn!"
30 END
100 PRINT "Me first!"
110 GOTO 20
 
RUN
Me first!
Now it's my turn!

Related to

GOSUB,RETURN

Operator GOSUB...RETURN

Syntax

GOSUB <line number>

Description

Execute a subroutine located on the specified line number and continue with the next statement after the subroutine has completed.

Examples
10 GOSUB 100
20 PRINT "Now it's my turn!"
30 END
100 PRINT "Me first!"
110 RETURN
 
RUN
Me first!
Now it's my turn!

Related to

GOTO,RETURN

Operator HEX$()

Syntax

HEX$(x)

Description

Returns a string with the hexadecimal representation of a (decimal) number.

Examples
10 PRINT "The hexadecimal representation of 8 is ",HEX$(8)
20 PRINT "The hexadecimal representation of 127 is ",HEX$(127)
 
RUN
The hexadecimal representation of 8 is 8
The hexadecimal representation of 127 is 7F

Related to

BIN$,OCT$

Operator IF...THEN...ELSE

Syntax

IF <condition expression> THEN <statement> [ELSE <statement>]

Description

Checks if a condition has been met and executes the statement specified after THEN. Optionally, if the condition has not been met the statement after ELSE will be run.

Examples
10 INPUT "What is your age",A
20 IF A < 18 THEN PRINT "You are way too young" ELSE PRINT "Good for you!"
 
RUN
What is you age?
Good for you!

Related to

Operator INKEY$

Syntax

a$=inkey$

Description

Returns either a single character read from the keyboard or (if no key is pressed) an empty string.

Examples
10 A$=INKEY$
20 IF A$="" THEN GOTO 10
30 PRINT "You pressed ",A$
 
RUN
You pressed M

Related to

INPUT,PRINT

Operator INPUT

Syntax

input [\"<prompt>\",]<x>

Description

Shows an optional prompt followed by a question mark, storing the input into variables. When retrieving data from the keyboard, this command shows an optional prompt followed by a question mark.

Examples
10 INPUT "What is your favorite computer system",A$
20 PRINT A$
 
RUN
What is your favorite computer system?
MCX

Related to

INKEY$,PRINT

Operator INSTR

Syntax

INSTR(A$,B$)

Description

Returns the position of the first occurrence of a B$ substring in A$ string, starting from an optional offset (x).

Examples
10 PRINT INSTR("I like MCX!","MCX");
 
RUN
8

Related to

LEN

Operator INT()

Syntax

INT(x)

Description

Returns the largest integer equal to or smaller than a variable.

Examples
10 PRINT "INT(1.23) results in ",INT(1.23)
20 PRINT "INT(-1.99) results in ",INT(-1.99)
30 PRINT "INT(-1.01) results in ",INT(-1.01)
 
RUN
INT(1.23) results in 1
INT(-1.99) results in -2
INT(-1.01) results in -2

Related to

FIX,CINT

Operator LEFT$()

Syntax

LEFT$(A$,x)

Description

Returns a string composed of the leftmost x characters of the string A$.

Examples
10 A$=LEFT$("MCX Forever!",3)
20 PRINT A$
 
RUN
MCX

Related to

MID$, RIGHT$

Operator LEN()

Syntax

LEN(X$)

Description

Returns the length of a string, including all non-printable characters.

Examples
10 PRINT LEN("MCX")
 
RUN
3
Related to

INSTR

Operator LET

Syntax

[LET] variable=x

Description

Assign data to the variable. LET is the command used to put a number in a variable. Here the = sign doesn€™t mean equals€¯ as it does in arithmetic. Instead, you can think of it as meaning that the number on the right goes into the variable on the left.€¯

Omitting LET

Variables are used very frequently in BASIC, and this means that the LET command is also used frequently. Because it is used so often, BASIC allows you to omit LET when you write a variable command. Instead of

LET A =10 you can simply write A = 10

Examples

LET A=A + 5

Related to

Operator LIST

Syntax

LIST [[<startline number>] [-<endline number>]]]

Description

Displays the program, or a part of it, in memory on screen.

Examples
LIST 10 - 30
10 FOR I=1 TO 5
20 PRINT I
30 NEXT I

Related to

Operator LOAD

Syntax

load "name"

Description

Load saved BASIC program. This command can load a BASIC program with a specific name.

Examples

load "myfile"

Related to

RUN,SAVE

Operator LOG()

Syntax

LOG(x)

Description

Returns the natural logarithm of a variable. Variable x must be greater than zero.

Examples
10 PRINT "The natural logarithm of 2 is ",LOG(2)
 
RUN
The natural logarithm of 2 is .69314718055993

Related to

Operator MID$()

Syntax

MID$(A$,x[,y])

Description

Returns a substring of variable length (y) starting at a variable position (x) in an input string a$. MID$ accepts an offset (x) between 1 and 255 and an optional length (y) between 0 and 255.

If no length (y) is specified then

- the entire substring starting at position x is returned

- the entire replacement string is used at position x

Examples
10 A$="www.msx.org"
20 PRINT MID$(A$,5,3)
30 PRINT MID$(A$,5)
 
RUN
msx
msx.org

Related to

LEN,LEFT$,RIGHT$

Operator OCT$()

Syntax

OCT$(x)

Description

Returns a string with the octal representation of a (decimal) number.

Examples
10 PRINT "The octal representation of 8 is ",OCT$(8)
20 PRINT "The octal representation of 127 is ",OCT$(127)
 
RUN
The octal representation of 8 is 10
The octal representation of 127 is 177

Related to

BIN$,HEX$

Operator POS

Syntax

POS

Description

Returns the horizontal coordinate of the cursor.

Examples
10 CLS
20 PRINT "Example of POS";
30 PRINT POS
 
RUN
Example of POS 14

Related to

CSRLIN

Operator PRINT

Syntax

print <expression>

Description

PRINT tells the computer to display whatever comes after it on the screen. This is a BASIC command, and therefore one that the computer can easily understand. When you write an expression (math formula) after PRINT, this tells the computer to do this calculation and display the answer on the screen.

Doing Various Calculations "10 + 5" is simple addition, but the computer can do other, more complicated, calculations, too. The following signs are BASIC calculating signs that the computer understands.

PRINT "character string"

This command is used to display words on the screen. The same PRINT command is used for words, also. Any word you want to print can be displayed by enclosing it in " ", after the PRINT command. Words enclosed in " " are called a character string.

Examples
10 CLS
20 PRINT "Example";
30 PRINT 14
 
RUN
Example 14

Related to

INKEY$,INPUT

Operator READ

Syntax

READ <read>

Description

Preparing data for variable values read-data.

Examples

				
10 cls
20 read name$
30 read country$
40 read age
50 read sex$
60 print name$+" "+country$+" "+age+" "+sex$
100 data "Mike","Poland",15,"Male"


				
Mike Poland 15 Male

Related to

DATA

Operator RESTORE

Syntax

RESTORE <line number>

Description

To allow DATA statements to be reread from a specified line.
If line number is specified, the next READ statement accesses the first item in the specified DATA statement.
If line number is omitted, the next READ statement accesses the first item in the first DATA statement.

Examples

				
10 cls
20 read name$
30 read country$
40 read age
50 read sex$
60 print name$+" "+country$+" "+age+" "+sex$
70 restore 100
80 read name$
90 print name$
100 data "Mike","Poland",15,"Male"


				
Mike Poland 15 Male
Mike

Related to

DATA

Operator RENUM

Syntax

renum

Description

Renumber the lines of a program, including all references to those lines by GOSUB, GOTO etc.

Examples
12 PRINT "HELLO"
34 PRINT "WORLD"
56 GOTO 12
RENUM
LIST

10 PRINT "HELLO"
20 PRINT "WORLD"
30 GOTO 10

Related to

Operator RETURN

Syntax

RETURN

Description

Returns from a subroutine that was invoked by GOSUB.

The program will return to this line when the execution of the subroutine is finished.

If you don't precise the line, the program will return to the statement directly after GOSUB.

Examples
90 ' RETURN without line
100 PRINT "Hello"
110 GOSUB 200
120 END
200 PRINT "Here am I"
210 RETURN
90 ' RETURN with line for infinite loop
100 PRINT "Hello"
110 GOSUB 200
120 END
200 PRINT "Here am I"
210 RETURN 100

Related to

GOSUB

Operator RND()

Syntax

RND(x)

Description

Returns a random value between 0 and x.

Examples
10 X=RND(100)
20 PRINT X;" is a random number between 0 and 100 ";
 
RUN
49 is a random number between 0 and 100

Related to

Operator RUN

Syntax

RUN ["name"]

Description

Execute program. This command can load and run a BASIC program with a specific name.

Examples
10 PRINT "The absolute value of 5 is ",ABS(5)
20 PRINT "The absolute value of -1.23 is ",ABS(-1.23)
 
RUN
The absolute value of 5 is 5
The absolute value of -1.23 is 1.23
Related to

LOAD

Operator SAVE

Syntax

SAVE "name"

Description

Saves a BASIC program.

Examples

save "myfile"

Related to

LOAD,RUN

Operator SIN()

Syntax

SIN(x)

Description

Returns the sine of a variable in radians.

Examples
10 PRINT "The sine of a 45 degree angle is ",COS(45)
20 PRINT "The sine of a 0 degree angle is ",COS(0)
 
RUN
The sine of a 45 degree angle is .85090352453482
The sine of a 0 degree angle is 0

Related to

ATN,COS,TAN

Operator SHARE

Syntax

SHARE "name"

Description

Saves a BASIC program and share.

Examples

share "myfile"

Related to

RUN, LOAD, SAVE

Operator SPC$()

Syntax

SPC$(x)

Description

Inserts a variable amount of spaces.

Examples
10 PRINT "MCX",SPC$(3),"Forever!"
 
RUN
MCX   Forever!

Related to

Operator SQR()

Syntax

SQR(x)

Description

Returns the square root of a variable. SQR accepts input equal to or higher than 0.

Examples
10 PRINT "The square root of 16 is ",SQR(16)
20 PRINT "The square root of 64 is ",SQR(64)
 
RUN
The square root of 16 is 4
The square root of 64 is 8

Related to

Operator STR$()

Syntax

STR$(x)

Description

Returns a string representation of a numeric variable.

Examples
10 A$=STR$(1.23)
20 PRINT A$
30 PRINT LEFT$(A$,2)
 
RUN
 1.23
 1

Related to

VAL

Operator STRING$()

Syntax

STRING$(x)

Description

Returns a string with a variable length (x), all containing either the same character, which is defined as an ASCII code (y).

Examples
10 PRINT STRING$(8,65)
 
RUN
AAAAAAAA

Related to

Operator TAN()

Syntax

TAN(x)

Description

Returns the tangent of a variable

Examples
10 PRINT "The tangent of 1 is ",TAN(1)
20 PRINT "The tangent of -1.23 is ",TAN(-1.23)
 
RUN
The tangent of 1 is 1.5574077246549
The tangent of -1.23 is -2.8198157342686

Related to

ATN,SIN,COS

Operator TIME

Syntax

time x$

Description

Reads the time to string variable.

Examples
DATA x$,a
Related to

DATE

Operator VAL()

Syntax

VAL(a$)

Description

Returns the numerical value of the contents of a string, omitting leading spaces, line feeds and tabs.

Examples
10 X=VAL("  1.23")
20 X=X+1
30 PRINT X
 
RUN
2.23

Related to

STR$

Operator VER

Syntax

ver

Description

Version of MCX Basic.

Examples

ver

Related to

Operator VARL

Syntax

varl

Description

Displays all variables and values on screen.

Examples

varl

Related to