ABS(x)
Returns the absolute value of a variable
10 PRINT "The absolute value of 5 is ",ABS(5) 20 PRINT "The absolute value of -1.23 is ",ABS(-1.23) RUNThe absolute value of 5 is 5 The absolute value of -1.23 is 1.23
ASC(x$)
Returns the ASCII value of the first character in a string
10 PRINT "The ASCII value of B is ",ASC("B") 20 PRINT "The ASCII value of MCX is -1.23 is ",ASC("MCX") RUNThe ASCII value of B is 66 The ASCII value of MCX is 77
ATN(x)
Returns the arctangent of a variable
10 PRINT "The arctangent of 1 is ",ATN(1) 20 PRINT "The arctangent of -1.23 is ",ATN(-1.23) RUNThe arctangent of 1 is .78539816339745 The arctangent of -1.23 is .88817377437769
auto
Starts automatic line numbering. The line number will start with 10, incrementing in steps of 10. To stop press 'ESC'.
auto
BIN$(x)
Returns a string with the binary representation of a (decimal) number
10 PRINT "The binary representation of 8 is ",BIN$(8) 20 PRINT "The binary representation of 127 is ",BIN$(127) RUNThe binary representation of 8 is 1000 The binary representation of 127 is 11011
CHR$(x)
Returns a string containing the ASCII character with the ASCII code of a variable.
10 PRINT "The character with ASCII code 67 is ",CHR$(67) 20 PRINT "I like ",CHR$(77),CHR$(67),CHR$(88) RUNThe character with ASCII code 67 is B I like MCX
CINT(x)
Returns the passed parameter rounded up.
10 PRINT "1.23 converted to integer is ",CINT(1.23) 20 PRINT "1.99 converted to integer is ",CINT(1.99) RUN1.23 converted to integer is 2 1.99 converted to integer is 2
clear
Sets all numeric variables to zero, all strings to null.
clear
COLOR <foreground>[,<background>]
Changes the color(s) to be used for the foreground and background.
COLOR 1,13
COS(x)
Returns the cosine of a variable in radians.
10 PRINT "The cosine of a 45 degree angle is ",COS(45) 20 PRINT "The cosine of a 0 degree angle is ",COS(0) RUNThe cosine of a 45 degree angle is .52532198881661 The cosine of a 0 degree angle is 1
csrlin
Returns the vertical coordinate of the cursor.
10 CLS 20 PRINT "Example of CSRLIN" 30 PRINT CSRLIN RUNExample of CSRLIN 1
DATA <data>
Store data in a program, to be read with the READ command
DATA 1,2,3,4,MCX," Forever! "
date x$
Reads the date to string variable.
DATA x$,a
DELETE <line number>[-<end line number>]
Erase part of an MCX-BASIC listing from memory.
10 PRINT "Haha! I am here to stay!" 20 PRINT "Oh no! I will be sent to oblivion!" DELETE 20 RUNHaha! I am here to stay!
dim <variable>(<size>)
Specify the dimension of an array.
10 DIM A(20) 20 A(20)=2 30 PRINT "In row 20 of array A I stored the value ",A(20) RUNIn row 20 of array A I stored the value 2
end
Close all open files (if any) and end program execution.
10 PRINT "The end is nigh!" 20 END 30 PRINT "I shall not be executed" RUNThe end is nigh!
exp(x)
Returns e (mathematical constant) to the power of x
10 PRINT "e to the power of 1 is ",EXP(1) 20 PRINT "e to the power of 0 is ",EXP(0) RUNe to the power of 1 is 2.7182818284588 e to the power of 0 is 1
fix(x)
Returns the integer part of a variable by truncating the numbers after the decimal point.
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) RUNFIX(1.23) results in 1 FIX(-1.99) results in -1 FIX(-1.01) results in -1
FOR <variable>=<start value> TO <end value> [STEP <increment>] ... NEXT
Sets up a loop in order to repeat a block of commands until the counter variable has reached (or exceeded) the end value.
10 FOR x=1 TO 25 STEP 5 20 PRINT x 30 NEXT RUN1 6 11 16 21
GOTO <line number>
Jump to the specified line number and execute the commands from there.
10 GOTO 100 20 PRINT "Now it's my turn!" 30 END 100 PRINT "Me first!" 110 GOTO 20 RUNMe first! Now it's my turn!
GOSUB <line number>
Execute a subroutine located on the specified line number and continue with the next statement after the subroutine has completed.
10 GOSUB 100 20 PRINT "Now it's my turn!" 30 END 100 PRINT "Me first!" 110 RETURN RUNMe first! Now it's my turn!
HEX$(x)
Returns a string with the hexadecimal representation of a (decimal) number.
10 PRINT "The hexadecimal representation of 8 is ",HEX$(8) 20 PRINT "The hexadecimal representation of 127 is ",HEX$(127) RUNThe hexadecimal representation of 8 is 8 The hexadecimal representation of 127 is 7F
IF <condition expression> THEN <statement> [ELSE <statement>]
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.
10 INPUT "What is your age",A 20 IF A < 18 THEN PRINT "You are way too young" ELSE PRINT "Good for you!" RUNWhat is you age? Good for you!
a$=inkey$
Returns either a single character read from the keyboard or (if no key is pressed) an empty string.
10 A$=INKEY$ 20 IF A$="" THEN GOTO 10 30 PRINT "You pressed ",A$ RUNYou pressed M
input [\"<prompt>\",]<x>
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.
10 INPUT "What is your favorite computer system",A$ 20 PRINT A$ RUNWhat is your favorite computer system? MCX
INSTR(A$,B$)
Returns the position of the first occurrence of a B$ substring in A$ string, starting from an optional offset (x).
10 PRINT INSTR("I like MCX!","MCX"); RUN8
INT(x)
Returns the largest integer equal to or smaller than a variable.
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) RUNINT(1.23) results in 1 INT(-1.99) results in -2 INT(-1.01) results in -2
LEFT$(A$,x)
Returns a string composed of the leftmost x characters of the string A$.
10 A$=LEFT$("MCX Forever!",3) 20 PRINT A$ RUNMCX
LEN(X$)
Returns the length of a string, including all non-printable characters.
10 PRINT LEN("MCX") RUN3
[LET] variable=x
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
LET A=A + 5
LIST [[<startline number>] [-<endline number>]]]
Displays the program, or a part of it, in memory on screen.
LIST 10 - 3010 FOR I=1 TO 5 20 PRINT I 30 NEXT I
load "name"
Load saved BASIC program. This command can load a BASIC program with a specific name.
load "myfile"
LOG(x)
Returns the natural logarithm of a variable. Variable x must be greater than zero.
10 PRINT "The natural logarithm of 2 is ",LOG(2) RUNThe natural logarithm of 2 is .69314718055993
MID$(A$,x[,y])
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
10 A$="www.msx.org" 20 PRINT MID$(A$,5,3) 30 PRINT MID$(A$,5) RUNmsx msx.org
OCT$(x)
Returns a string with the octal representation of a (decimal) number.
10 PRINT "The octal representation of 8 is ",OCT$(8) 20 PRINT "The octal representation of 127 is ",OCT$(127) RUNThe octal representation of 8 is 10 The octal representation of 127 is 177
POS
Returns the horizontal coordinate of the cursor.
10 CLS 20 PRINT "Example of POS"; 30 PRINT POS RUNExample of POS 14
print <expression>
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.
10 CLS 20 PRINT "Example"; 30 PRINT 14 RUNExample 14
READ <read>
Preparing data for variable values read-data.
10 cls20 read name$30 read country$40 read age50 read sex$60 print name$+" "+country$+" "+age+" "+sex$100 data "Mike","Poland",15,"Male"
Mike Poland 15 Male
RESTORE <line number>
10 cls20 read name$30 read country$40 read age50 read sex$60 print name$+" "+country$+" "+age+" "+sex$70 restore 10080 read name$90 print name$100 data "Mike","Poland",15,"Male"
Mike Poland 15 MaleMike
renum
Renumber the lines of a program, including all references to those lines by GOSUB, GOTO etc.
12 PRINT "HELLO" 34 PRINT "WORLD" 56 GOTO 12
RENUM LIST 10 PRINT "HELLO" 20 PRINT "WORLD" 30 GOTO 10
RETURN
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.
90 ' RETURN without line 100 PRINT "Hello" 110 GOSUB 200 120 END 200 PRINT "Here am I" 210 RETURN90 ' RETURN with line for infinite loop 100 PRINT "Hello" 110 GOSUB 200 120 END 200 PRINT "Here am I" 210 RETURN 100
RIGHT$(A$,x)
Returns a string composed of the right x characters of the string A$.
10 A$=RIGHT$("MCX Forever!",8) 20 PRINT A$ RUNForever!
RND(x)
Returns a random value between 0 and x.
10 X=RND(100) 20 PRINT X;" is a random number between 0 and 100 "; RUN49 is a random number between 0 and 100
RUN ["name"]
Execute program. This command can load and run a BASIC program with a specific name.
10 PRINT "The absolute value of 5 is ",ABS(5) 20 PRINT "The absolute value of -1.23 is ",ABS(-1.23) RUNThe absolute value of 5 is 5 The absolute value of -1.23 is 1.23
SIN(x)
Returns the sine of a variable in radians.
10 PRINT "The sine of a 45 degree angle is ",COS(45) 20 PRINT "The sine of a 0 degree angle is ",COS(0) RUNThe sine of a 45 degree angle is .85090352453482 The sine of a 0 degree angle is 0
SPC$(x)
Inserts a variable amount of spaces.
10 PRINT "MCX",SPC$(3),"Forever!" RUNMCX Forever!
SQR(x)
Returns the square root of a variable. SQR accepts input equal to or higher than 0.
10 PRINT "The square root of 16 is ",SQR(16) 20 PRINT "The square root of 64 is ",SQR(64) RUNThe square root of 16 is 4 The square root of 64 is 8
STRING$(x)
Returns a string with a variable length (x), all containing either the same character, which is defined as an ASCII code (y).
10 PRINT STRING$(8,65) RUNAAAAAAAA
TAN(x)
Returns the tangent of a variable
10 PRINT "The tangent of 1 is ",TAN(1) 20 PRINT "The tangent of -1.23 is ",TAN(-1.23) RUNThe tangent of 1 is 1.5574077246549 The tangent of -1.23 is -2.8198157342686
VAL(a$)
Returns the numerical value of the contents of a string, omitting leading spaces, line feeds and tabs.
10 X=VAL(" 1.23") 20 X=X+1 30 PRINT X RUN2.23
varl
Displays all variables and values on screen.
varl