Page 1 of 1

Smart BASIC Programming. Lesson 1

Posted: Thu Oct 02, 2014 4:41 pm
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.

Re: Smart BASIC Programming. Lesson 1

Posted: Fri Oct 03, 2014 11:00 pm
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

Re: Smart BASIC Programming. Lesson 1

Posted: Sat Oct 04, 2014 3:20 am
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.