📜 ⬆️ ⬇️

Small Basic - for those who are just starting

image
Hello everyone, and special greetings to those who want to start programming, and do not know what to start with or what development environment to prefer.

Today I will talk about such a wonderful thing as Small Basic.

And yet, for whom Small Basic? Logical - for those who want to start programming. In order to start programming, the experience is completely unnecessary, but if there is, it is even better.

Quite bad, it would be, if at the same time, in lessons of computer science of high school or students, besides Pascal and Turbo-BASIC, allocating watches on Small Basic would be useful.
')

First start.


image
Very good window, nothing superfluous.

Pleasant moments.


image
Here is a special thank you for this, this is a very convenient thing. Arrow control, Russian description. Your assigned variables are also supported. The process becomes very enjoyable.

Appendix.


On the microsoft site, and during the installation, the initial documentation is also put up, which in a very clear language will introduce you to Small Basic and the programming process as a whole.

Unfortunately, SB is not a very big opportunity. But this allows the student, after sufficiently mastering the SB, to move to a more professional level.

SB supports the connection of external libraries, which greatly expands the possibilities.

For Russians, there is an official Russian-speaking community of novice programmers. Version 0.8 is also available there.

The advantages are obvious if for all the well-known “first application” Hello Word in Small Basic is enough:
TextWindow.WriteLine("hello word")
C ++
main()
{
cout << "Hello World!" << endl;
return 0;
}

In the language of pascal
program HelloWorld(output);
begin
WriteLn('Hello World!');
end.


Of course, you can choose, but the difference is palpable, although I don’t compare C ++ programming with Small Basic, but what to learn

A small example, flying balls.


image

The most interesting thing is that the program is only 15 lines:

For i = 1 To 100
balls[i] = Shapes.AddEllipse(10, 10)
EndFor

While "True"
For i = 1 To 100
ball = balls[i]

x = Math.GetRandomNumber(640)
y = Math.GetRandomNumber(480)
Shapes.Animate(ball, x, y, 2000)
EndFor
Program.Delay(1900)
EndWhile


And now analyze the code.


The source code can be divided into 2 parts.
The first operation For is a cycle, with the help of this cycle we will set our variable to the initial and final value, the increment of the variable will be done automatically by the computer.

We will add a variable to the loop, call it “balls”, and inside the variable, give the SB command “Shapes”, it allows you to add, move and rotate figures, add an “AddEllipse” operation to the object (Shapes), which serves to add an ellipse with a given height and wide. End the loop with the EndFor command.

In the second part of the code, we again use a loop, but of a different construction. Another construction is necessary if the counter-loop variable is not known in advance, if the For loop is executed as many times as we specify, the While loop is executed until the condition is met.

In the While loop, we include a For loop, in which we will create a variable ball equal to balls [i] (i - all values ​​from 1 to 100).

Add variables for x and y coordinates. To do this, we use the Math class, which provides many mathematical operations. To the class we assign the operation GetRandomNumber, which gives a random number in the given parameter maxNumber, which in turn will be indicated in brackets.

Then again, we give the SB command “Shapes”, but this time we assign the Animate operation, which moves the ball to the new position (x, y) using animation and set the animation time in seconds 2000. We end the For loop with the EndFor command.
We use the Program class, which serves to control the application itself, assign the Delay operation to it, which delays the execution of the program by 1900 ms. And at the end we stop the While loop with the EndWhile command.

Run the program with the F5 button. Actions are as follows:
Loop loop from 1 to 100 for the variable balls, which draws an ellipse 10x10, the end of the loop. Drawing heaps of ellipses.
So, draw ellipses, so - a program delay (Program.Delay (1900) ms). The While loop, which scatters ellipses along the x, y coordinates (which are randomly set, remember Math.GetRandomNumber), the animation time is 2000 ms. We are waiting - we repeat. We are waiting - we repeat.

The only problem is the size, the size of even such a small program is 236 KB, but this is due to the fact that to run * .exe, you need the SmallBasicLibrary.dll dll-library, without it the size of the program is only 3 kb.

Source: https://habr.com/ru/post/87447/


All Articles