Smart BASIC Programming. Lesson 1

Post Reply
User avatar
Mr. Kibernetik
Site Admin
Posts: 4782
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Smart BASIC Programming. Lesson 1

Post by Mr. Kibernetik »

Lesson 1 - Variables

Smart BASIC language is very simple. It has only two variable types - numeric and string.

Numeric variables are used for calculations and numbers storage:

Code: Select all

A = 2
B = A * 3
String variables are used for text storage:

Code: Select all

T$ = "Hello!"
String variable has "$" character at the end of its name.

Besides variables, smart BASIC uses commands and functions.
Commands perform some task, for example PRINT command prints text on the screen:

Code: Select all

PRINT "This is a text"
And INPUT command asks user a question:

Code: Select all

INPUT "How old are you?" : YEAR
PRINT "I already know that you are " & YEAR & " years old"
PRINT "Next year you will be " & (YEAR + 1)
Functions return some result, for example:

Code: Select all

PRINT "You have " & DEVICE_TYPE$ ()
PRINT "with screen size " & SCREEN_WIDTH () & " points"
Functions have brackets "( )" and also have "$" symbol if they return text.

FOR PROGRAMMERS
Smart BASIC does not require variables definition and also allows usage of numeric variables in string expressions and string variables in numeric expressions. Smart BASIC automatically converts between text and numbers in expressions and commands parameters, so it is correct to write:
A = 2 + "3"
or
T$ &= SIN (X)

EXERCISE 1
Write a program which asks user the sizes of two catheti and prints on screen the size of hypotenuse of this right triangle.

Dalede
Posts: 131
Joined: Fri Dec 28, 2012 4:00 pm
Location: Grass Valley, CA, USA
Contact:

Re: Smart BASIC Programming. Lesson 1

Post by Dalede »

Looks like a good start but it fails to define some of the symbols used in the examples and others that are needed to solve the exercise. For example & is not defined before it used or even after. the Divide symbol is not defined. * is used by not defined. comments should be defined early.

Dale

User avatar
Mr. Kibernetik
Site Admin
Posts: 4782
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Smart BASIC Programming. Lesson 1

Post by Mr. Kibernetik »

Dalede wrote:Looks like a good start but it fails to define some of the symbols used in the examples and others that are needed to solve the exercise. For example & is not defined before it used or even after. the Divide symbol is not defined. * is used by not defined. comments should be defined early.

Dale
Thank you for your comments Dale. These lessonds don't replace documentation - they are an addendum to it. They inspire to read documentation and they explain those practical things which cannot be listed in the manual.

Post Reply