MSX BASIC – lesson 9

da | Nov 20, 2023 | MSX BASIC | 0 comments

“MSX BASIC” COLUMN by Orazio Cacciola (part 9)

OVERVIEW OF MSX BASIC FUNCTIONS AND COMMANDS

Greetings to everyone.
Since in the previous "episodes" I mentioned functions that I had not explained, in this one I will propose them together with others that are easy to understand.

CLS: Clears the screen, both text and graphics.
Syntax: CLS

END: Ends execution of a program and closes all open files.
Syntax: END

GOTO: Send program execution to the specified line.
Example: 200 GOTO 100. When the program encounters this function it will automatically go to the specified line. It is called as unconditional jump.
Syntax: GOTO Line Number

INPUT: Waits for data entered from the keyboard, displaying a question mark, which will be confirmed with the ENTER key, both numeric and string. You can enter text that will appear before the question mark. You can enter multiple variables, just divide them by a comma. Let's remember that the variables must respect the order, that is, if the first entry is a number and the second is a sentence we cannot reverse them, otherwise the MSX reports the error.
If, however, we have made more entries and we confirm before they have been made, it will display 2 question marks, this to say that it is still waiting for one or more data. A very important thing is not to use a comma inside a sentence you are typing, otherwise the MSX will understand that we have entered 2 variables and will report the error. While you are typing the sentence, if you make a mistake, you are allowed to use the correction keys: INS/DEL/BACKSPACE.
Examples: INPUT “Enter a number”;N or INPUT “What is your name and how old are you”;N$,E or INPUT A
In the first example it will ask for the insertion of a number after the text, in the second, again after the text, we will have to insert a string and a number followed by a comma, in the third only a question mark will appear on the screen and it will wait for the insertion of a number.
Syntax: INPUT [“Text”;]Variable [,Variable] …..

LINE INPUT: It is almost the same as the previous one. The differences are: it only accepts strings with a maximum of 254 characters, it does not display the question mark, it does not recognize denominators (commas) and you can only use a string variable.
Syntax: LINE INPUT [“Text”;] Variable$

LET: Assign a value to a variable. It is not required in MSX Basic.
Syntax: [LET] A = 15 + 54

REM: It is used to insert notes, notes or anything else at any point in the program. Everything after that is not read by BASIC. It is widely used when programs become complex, to remember what it is doing at that particular point. You can also use the '(apostrophe) symbol which is the abbreviation of the command.
Tip: Even if the string that follows after the command is not read by BASIC, it will occupy bytes in memory and this, in addition to making our programs bigger, will slow them down. Use it sparingly.
Syntax: REM Comment or ' Comment

SWAP: Swap the values of 2 variables. Example: if A=10 and B=20 using SWAP A,B the values will become A=20 and B=10. This function is valid only with numeric variables.
Syntax: SWAP Variable1, Variable2

See you next time.
Thank you and enjoy the weekend.

0 Comments

Submit a Comment

Your email address will not be published. I campi obbligatori sono contrassegnati *

LEZIONE 26 – INTERVAL ON, RND ED ALTRI

LESSON 26 – INTERVAL ON, RND AND OTHERS

Good morning everyone, In this episode I will talk about an important interrupt, especially for games, when we want to make an enemy suddenly appear or a useful object, but also to create a stopwatch or a clock and many other things. The COMMAND exploits the...

LEZIONE 26 – INTERVAL ON, RND ED ALTRI

LESSON 24 – THE DATA MANAGED BY THE MSX (PART 3)

Kind regards to everyone. Today we will close this topic, I will talk about direct or random access files. But first, as I mentioned in the last episode, I will give a small explanation about the program. First of all, the first thing to say is that I used a command which...