background top icon
background center wave icon
background filled rhombus icon
background two lines icon
background stroke rhombus icon

Download "Кроссплатформенная разработка с Lazarus/ObjectPascal/Delphi. Программирование #ityoutubersru"

input logo icon
Video tags
|

Video tags

Программирование
Паскаль
Pascal
Delphi
Lazarus
Windows
Linux
OSX
Разработка
Программирование для начинающих
GUI
Окна
Компоненты
Интерфейс
UI
Нативный код
Компилятор
Отладка
Релиз
Окно
ОС
ityoutubersru
программирование
objectpascal
ityoutubers
Subtitles
|

Subtitles

subtitles menu arrow
  • ruRussian
Download
00:00:02
usual Peter
00:00:03
my subscribers have asked me many times to
00:00:05
make videos about programming and I
00:00:07
finally decided to do it
00:00:09
naturally I would like everyone to be
00:00:11
able to repeat what I do in my
00:00:13
videos and for this I need to find some kind
00:00:15
such a development environment, when installed,
00:00:18
compilers are installed with all the
00:00:20
necessary utilities
00:00:21
so that they do not need to be configured
00:00:22
manually; in addition, it is extremely important for me
00:00:25
that the development is carried out in some kind of
00:00:26
compiled language that allows you to
00:00:29
create independent binaries
00:00:31
and also that it is possible to easily and
00:00:33
simply create a graphical
00:00:34
user interface and since my subscribers
00:00:37
use different operating systems,
00:00:39
that development environment must work on
00:00:41
windows linux and os x and in fact
00:00:45
only two development environments
00:00:46
meet these criteria, namely
00:00:49
whales crater and programming in
00:00:51
C plus plus and lazarus
00:00:54
and programming in Roasting
00:00:55
Pascal Having considered all the pros and cons, in
00:00:58
the end I chose Lazarus and
00:01:00
programming in the object pascal language.
00:01:02
If you really don’t like the
00:01:04
Pascal language, then don’t rush to turn off this
00:01:06
video, maybe I’ll be able to convince you
00:01:08
in this video, I’ll tell you why I
00:01:11
chose Lazarus Nikita Crater
00:01:13
how to install Lazarus on various
00:01:16
operating systems, I
00:01:17
’ll tell you a little about the syntax of the
00:01:19
Pascal firing language, we’ll write some
00:01:22
simple console applications and
00:01:24
of course I’ll show you how to create an
00:01:25
application with a graphical
00:01:27
user interface, which in my opinion is very
00:01:30
interesting, in addition, I’ll talk a little
00:01:32
about debugging applications and how
00:01:35
to make a release of your application, in
00:01:38
general, about an hour awaits you, I hope there is
00:01:40
quality content, so pour
00:01:43
a beer, brew some tea og and let's go,
00:01:56
why did
00:01:58
I choose lazarus to use my videos,
00:02:00
they are qt creator, the qt creator environment is tailored
00:02:03
for C plus plus,
00:02:04
while Lazarus is for burning pascal
00:02:06
and in my opinion, for people who don’t
00:02:08
know either one or the other, it
00:02:10
will be easier to understand the code in pascal.
00:02:11
Another disadvantage of titek reuter is
00:02:14
that in the free version it prohibits
00:02:16
dealing with ethical binaries, so with
00:02:19
your application you have to carry
00:02:21
a bunch of them with you dynamic libraries,
00:02:23
but there is another significant reason,
00:02:25
namely the constant change in the licensing
00:02:27
policy and the cabin of the company, which has
00:02:30
recently been doing some crazy things on the
00:02:32
official website of gt to find a free
00:02:34
version of China Crater and now it is very
00:02:36
difficult free tls releases have been completely
00:02:40
canceled the company is changing licenses for
00:02:42
some components from lgpl to gpl and
00:02:46
new components are created under the
00:02:48
gnu gpl license version 3 which is
00:02:51
so free that you are simply obliged to
00:02:54
open the source code of your programs without
00:02:55
any exceptions, in addition, where the
00:02:58
lgpl license remains,
00:03:00
it is used by the third version, which
00:03:02
practically prohibits making any
00:03:04
built-in the application has even reached the point of
00:03:07
absurdity; the offline installer is now available
00:03:09
only under a commercial license; in
00:03:12
fact, it is clear why this is being done;
00:03:14
this is being done so that users of the
00:03:16
qt framework buy the commercial
00:03:18
version, which now costs 4 thousand
00:03:20
dollars per year per developer,
00:03:22
which I consider too much money as
00:03:25
and many users of the cabin are funny that
00:03:28
on some sites the developers are now
00:03:30
seriously considering switching back to
00:03:32
Delphi, in fact, the catacombs they
00:03:34
would have removed the free version long ago and
00:03:36
perhaps would have completely closed the source code;
00:03:39
this is hindered by the agreement that was
00:03:40
concluded with the pdf ricketty foundation
00:03:43
in ninety-eight, which obliges
00:03:45
publish all sources within 12
00:03:48
months after they are changed;
00:03:50
however, here too the Chinese company found
00:03:52
a loophole; they are going to publish
00:03:54
sources for free users
00:03:56
only 12 months after the release;
00:03:59
to be honest, I have no
00:04:01
desire to dive into the intricacies of
00:04:03
qt licensing and changes in
00:04:06
company policy, so I I chose
00:04:08
Lazarus
00:04:09
and programming in the Roast
00:04:11
Pascal language, and in the end I just
00:04:13
love the Roast Pascal language, and the
00:04:16
Lazarus license is much more liberal, it is
00:04:18
based on lgpl
00:04:20
and, among other things, it has an important
00:04:22
exception, it allows static
00:04:25
linking, that is, you can do
00:04:27
plaza in Russia both free and paid
00:04:29
applications are closed source and a
00:04:32
single binary without any
00:04:34
dynamic libraries in the general license
00:04:36
Lazarus does not impose
00:04:38
almost any restrictions on you Lazarus
00:04:41
is a completely independent non-commercial
00:04:43
project that is being developed by a team of
00:04:46
developers distributed around the
00:04:47
world as a compiler Lazarus
00:04:50
uses free pascal which
00:04:52
is also a completely non-commercial
00:04:54
product and although the non-commercial
00:04:56
Lazarus certainly has more flaws
00:04:58
than the commercial product from this company to
00:05:00
this company, this is a really good
00:05:02
development environment, I’m almost sure
00:05:07
that under this video, as with any
00:05:09
mention of the Pascal language in RuNet,
00:05:11
a bunch of comments will appear like what is
00:05:14
Pascal I’m looking for used Pascal is dead,
00:05:17
but does anyone else write in Delphi?
00:05:19
Pascal is used only in Russia,
00:05:21
abroad, no one uses it, no one
00:05:23
writes commercial words in Pascal, they
00:05:26
still know that Pascal is used
00:05:28
only for learning, bury this
00:05:30
language already and haven’t mastered it at school begins, that’s
00:05:35
enough absurd, once
00:05:36
I was convinced of the death of pascal by a person from the
00:05:38
humanities who had
00:05:40
never programmed in anything at all, it just
00:05:42
so happened that in Russia everyone knows that
00:05:44
Pascal or Delphi are dead I will answer all
00:05:47
such comments right now in
00:05:49
reality there are at least three
00:05:51
commercial development environments for pascal
00:05:53
this is of course a wonderful environment from the
00:05:55
embarcadero company called
00:05:57
delphi there is also just a formal environment
00:06:00
called oxigin and for programming
00:06:02
microcontrollers there is the micro
00:06:04
pascal environment the most famous free
00:06:06
development environment is of course
00:06:07
lazarus but if there are some others are there yes m
00:06:11
s I also use free pascal
00:06:13
as a complement
00:06:14
there are also smaller projects such as for
00:06:16
example diesel pascal
00:06:18
there is also an interesting project
00:06:20
called pascal a b c no which was
00:06:22
created specifically for teaching I think it is
00:06:25
obvious that a dead language cannot
00:06:27
have so much development trail, some of
00:06:28
which are commercial
00:06:30
and about the programs that are written on
00:06:32
pascal in this case on Delphi, then you are
00:06:34
most likely watching this video of a device
00:06:36
in the design of which
00:06:37
altium designer was used,
00:06:40
this is a huge application that is written
00:06:42
in Delphi when you listen to your favorite
00:06:44
music, then most likely you listen to
00:06:46
tracks that were written using
00:06:48
fruity loops studio which is also
00:06:50
written in Delphi and with a certain degree of
00:06:52
probability you listen to music using the
00:06:54
aimp program which is also written in
00:06:57
Delphi,
00:06:58
also in Delphi a well-known
00:06:59
board tracer called diptrace
00:07:02
sprint-layout was written which you may
00:07:04
use is also written in Delphi
00:07:06
and in the end the circuits for with a video on
00:07:08
my channel I draw a program written
00:07:10
in Delphi called c plan, if
00:07:13
we talk specifically about the eyes of Russia, then in
00:07:15
Vine of Russia there is a 6 4-bit version of
00:07:17
total commander,
00:07:19
but perhaps you prefer free
00:07:21
software and use before was commander,
00:07:23
but it is also written in Vine of Russia a
00:07:25
free analogue of paint.net
00:07:27
called laz paint, another
00:07:29
program made by the eyes of Russia, also
00:07:31
Lazarus is actively used in science and
00:07:32
scientific research,
00:07:34
quite a lot of scientific software is written on it,
00:07:37
Lazarus is also popular for writing
00:07:39
medical software, one of the programs has
00:07:41
completely survived the change in hardware and
00:07:43
software platforms in Apple computers
00:07:45
and regarding the fact that the majority of
00:07:47
Pascal developers are from Russia, this
00:07:49
has nothing to do with the truth, if we
00:07:52
talk about games here,
00:07:53
Pascal is really not the most popular tool, but
00:07:56
nevertheless, a game like Cossacks 3 from
00:07:58
gsc or, for example, a free clone of a thief
00:08:01
called Hogwarts was written
00:08:03
As you can see, in Pascal, contrary to stereotypes,
00:08:06
a lot of good and popular software has been written on Pascal,
00:08:09
but it is worth admitting that indeed, even after
00:08:12
many years of anti-hype, Pascal is not as
00:08:14
popular with
00:08:15
new developers as it could be, but who
00:08:17
knows, it’s possible and I’m sorry, it’s
00:08:19
certainly worth starting with your videos from
00:08:22
installing Lazarus, I will show you how to
00:08:24
install Lazarus, but such operating
00:08:26
systems as windows and os x and linux,
00:08:29
I will also tell you how you can install
00:08:32
Lazarus on other operating systems,
00:08:36
installing Lazarus on an operating
00:08:39
system from Microsoft is the simplest, all
00:08:41
you need to do is go to the
00:08:43
official Lazarus website and gives dot
00:08:45
org and download the Lazarus installer for
00:08:47
your operating system Putin
00:08:50
32-bit or 64-bit
00:08:52
As a rule, the site itself determines your
00:08:55
operating system after launching the
00:08:57
installer, select
00:08:59
your preferred language and the installer clicks on the
00:09:02
next button, it’s
00:09:03
better not to change the Lazarus installation directory
00:09:05
so as not to get it in the future there are
00:09:06
some glitches, don’t worry,
00:09:09
Lazarus takes up very little space on
00:09:11
your system disk; also, if you wish,
00:09:14
you can create an icon on the desktop.
00:09:16
Now, after clicking on the
00:09:18
install button, you need to wait a little while
00:09:20
lazarus is installed.
00:09:22
When you first start, the Lazarus settings window will appear
00:09:25
in it, you need to make sure
00:09:27
that all the necessary
00:09:28
components for work are installed and lazarus is installed, namely the
00:09:31
lazarus compiler itself, the source code, the make
00:09:34
and the debugger, as soon as you are sure that
00:09:37
everything is fine, feel free to click the
00:09:39
launch kernel button, lazarus has started and opened the project
00:09:43
by default, this is an empty application with
00:09:45
one form for convenience, I recommend
00:09:49
opening the inspector window project to
00:09:51
make it convenient to navigate through the
00:09:53
files of your project,
00:09:56
let's finalize the standard
00:09:58
application, add one button to the form,
00:10:01
when clicked, a
00:10:03
dialog box with a
00:10:05
welcome message will be displayed on the screen,
00:10:09
launch our application, as you can see,
00:10:12
compilation due to the one-pass sti
00:10:14
compiler
00:10:15
is quite fast and here we are
00:10:17
got the first native application
00:10:19
for Windows,
00:10:22
most programmers prefer the
00:10:24
dark theme of the code editor, I’ll
00:10:26
be honest, I’m no exception, so let’s
00:10:28
turn it on in the parameters and settings,
00:10:32
also for clarity, I recommend
00:10:34
turning on the display of block outlines by
00:10:39
default, Lazarus displays its
00:10:41
interface in several windows and the
00:10:43
interface is very similar to the interface
00:10:44
delphi 7
00:10:46
but not everyone will like this interface,
00:10:48
you may prefer 1
00:10:50
horse program
00:10:51
if you want to enable the new mode
00:10:54
then go to the package manager select
00:10:57
the package whose name you see on the
00:10:59
screen this is an experimental package but
00:11:01
works quite well click
00:11:04
install selected
00:11:05
then click save and launch the kernel
00:11:08
and agree with the changes and the vine once
00:11:11
within a few minutes Perry will compile
00:11:13
itself from the source code, taking into account the
00:11:15
selected package, well, as you will see,
00:11:20
Lazarus Perry has launched, its interface
00:11:22
resembles modern versions of Delphi,
00:11:25
let's turn off the not very beautiful
00:11:26
window headers and add a
00:11:29
project manager in general -that’s all, setting up
00:11:32
Lazarus for programming on the
00:11:34
Windows platform is complete. Now let’s
00:11:38
consider installing Lazarus on the
00:11:40
Linux operating system,
00:11:42
and more specifically on ubuntu, on the
00:11:45
official Lazarus website there are both grandfather
00:11:47
and RPN packages that cover most
00:11:49
Linux distributions. Let’s
00:11:51
make sure that the Lazarus website correctly
00:11:54
identified our operating system. the system
00:11:55
here is written debian 6 4 ubuntu this is
00:11:59
a distribution based on the case not as you
00:12:04
see on the download page there are three
00:12:06
packages available we need to download each after the
00:12:09
packages are downloaded
00:12:10
they should be installed strictly in the following
00:12:12
order first in palace this is the
00:12:15
free pascal compiler then vpc
00:12:17
heart these are the original ones codes and finally
00:12:20
lazarus project we install these packages
00:12:24
one after another and as you can see
00:12:27
program managers we have a lazarus icon
00:12:30
after launching lazarus a configuration window opens
00:12:32
in which you need to make sure
00:12:34
that all the necessary components
00:12:35
are installed after which you can safely
00:12:38
press the start button first of all I
00:12:40
will install the package for 1 windowed
00:12:42
operating mode, etc. in order to make sure
00:12:45
that we did everything correctly and lazarus
00:12:47
can rebuild itself from the source code
00:12:55
after a few minutes, Lazarus Perry
00:12:57
launched in however, it
00:13:00
now makes sense for us to add a
00:13:02
project inspector window, let's make the
00:13:07
simplest application,
00:13:08
change the loaded default project,
00:13:10
add a button to the formula when you click
00:13:13
which you see is a welcome window, let's
00:13:17
launch our project and after a
00:13:20
short compilation we can
00:13:21
make sure that we have just written the
00:13:23
simplest application using
00:13:26
gtk plus,
00:13:27
and on Linux by default Lazarus
00:13:29
creates an application using the
00:13:31
gtk 2 widget library,
00:13:33
but you may ask why such a
00:13:35
decoction they gtk 3 because the gtk 3 library
00:13:38
has existed for several years and it’s time to
00:13:40
switch to it; in fact,
00:13:43
there is support for gt3 applications from the eye of Russia,
00:13:45
but it is in alpha mode,
00:13:48
this is caused by many reasons, including the fact
00:13:50
that the gd library for 3 manages to break
00:13:53
compatibility with itself itself at the level of
00:13:54
source codes of minor releases, not to
00:13:57
mention compatibility at the binary
00:14:00
level, and in general there are questions about the gtk 3 architecture
00:14:02
and many programs, not
00:14:05
only Lazarus, continue to use
00:14:06
gtk 2, even such a program as Jim, a
00:14:09
fairly well-known one, continues to
00:14:11
use the gtk 2 library
00:14:13
despite the fact that that gtk stands
00:14:15
for jim toolkit and initially gtk
00:14:17
was created specifically for this program,
00:14:20
naturally, by analogy with windows, you
00:14:22
can upset other parameters of the
00:14:24
development environment on this installation and configuration of
00:14:27
lazarus under ubuntu china law
00:14:31
what is the
00:14:33
time to reinstall the chance although no
00:14:38
wait now we will install
00:14:40
lazarus on operating system madjar and
00:14:43
linux
00:14:44
manjari linux is an arch which
00:14:46
naturally does not support grandfather or rpn
00:14:48
packages, however, in the standard
00:14:51
package managers of this operating system there is a
00:14:53
fresh release of vase russo.
00:14:54
In any case, if you install
00:14:57
Lazarus on other linux distributions,
00:14:58
make sure that you
00:15:01
have the latest version in the repository lazarus if
00:15:03
your distribution supports rpn or deb
00:15:06
packages, I highly recommend downloading
00:15:08
lazarus from the official website
00:15:10
as in previous times, when you
00:15:12
launch it for the first time, lazarus will display a setup window in
00:15:14
which you need to make sure that all the
00:15:16
necessary components are installed on the
00:15:18
system, so let’s launch lazarus and write
00:15:22
a program that will display when you
00:15:23
click on the button at the jar hill, we
00:15:28
launch it and as you can see our
00:15:31
application works perfectly, I think you
00:15:35
have already noticed that I have a madjar with a
00:15:37
desktop environment for
00:15:39
which native applications are
00:15:41
applications written using fimor
00:15:44
like ut and by default As I already said,
00:15:47
Lazarus creates disgustingly two applications behind the
00:15:50
scenes, I have already configured Lazarus and now I
00:15:52
propose to talk about how to create
00:15:54
qt applications in Vine Rus first
00:15:58
let's write a small code that
00:16:00
will display in a pop-up window what
00:16:02
widget library is used the code is
00:16:05
made using conditional compilation in
00:16:09
order for there to be support for applications,
00:16:12
you need to install the appropriate package
00:16:15
package for creating kits of
00:16:17
Eye of Russia applications I found in the standard
00:16:19
package manager from the heat,
00:16:23
now we need to go to the settings of our
00:16:25
project, go to the
00:16:29
target platform settings tab and select another
00:16:32
widget library, we will select the
00:16:34
kit e5 widget library,
00:16:36
save settings and launch our
00:16:39
application again,
00:16:42
well, as you can see, we have created an
00:16:44
application that uses the
00:16:45
widget library in those five and looks native for
00:16:48
this desktop manager before
00:16:53
I tell you how to install Lazarus on
00:16:55
apple os x a little historical
00:16:57
background the
00:16:58
original classic makos was
00:17:01
written in assembler and pascal and
00:17:03
and piya and for applications, respectively, it
00:17:05
was also rocky, this thing was called a
00:17:07
mac tool-box, in principle, this 35 was
00:17:10
convenient not only for pascal but also for
00:17:12
programs that were written in C and all the
00:17:14
developers, in principle, were happy with it in the
00:17:17
ninety-sixth year of apple announced
00:17:19
its new operating system written from scratch
00:17:21
which we now
00:17:23
know under the name
00:17:24
os x this operating system was
00:17:27
made on the basis of next and was unix-like in the
00:17:30
graphical quality of this new
00:17:32
operating system from apple there was a device of which
00:17:35
this repair was very cool but
00:17:37
was inconvenient for the developers who
00:17:39
they develop in languages ​​different from the
00:17:41
language of the object, everything except for it it
00:17:44
was necessary to rewrite the application
00:17:46
almost from scratch,
00:17:48
this one was very different from the classic
00:17:50
and pr for the Macintosh, however, support for the
00:17:54
old and pr was removed, this outraged a
00:17:57
large number of developers and even
00:17:59
microsoft said that they will
00:18:01
rewrite
00:18:02
their code for a new development platform
00:18:04
called which, and already in
00:18:08
1990, under the pressure of developers, apple
00:18:10
announced its new and before for
00:18:12
developing applications called
00:18:14
carbon, in fact it was a slightly
00:18:16
modified tool-box,
00:18:17
its main advantage was that the
00:18:19
application was not needed to rewrite from scratch
00:18:21
you just need to make small changes
00:18:24
since carbon and drunk was developed
00:18:27
on the basis of the classic rock
00:18:29
from apple on classic macintoshes their
00:18:31
developers of lazarus began to use
00:18:34
it and lazar worked perfectly on the
00:18:36
operating system from apple by the way
00:18:38
apple itself actively used carbon
00:18:41
right up to 2009 but in 2012 apple
00:18:45
said that the carbon api was outdated and the carbon
00:18:48
api would no longer be updated, new
00:18:50
functions would not appear
00:18:51
and there would be no 6 four-bit carbon api either,
00:18:54
so lazarus began to
00:18:56
gradually add support for which,
00:18:58
but this support was added quite
00:19:01
slowly because Lazarus is the principle it
00:19:03
worked so well until finally in 2019
00:19:06
ice x catalina came out which
00:19:09
killed support for 32-bit applications and
00:19:12
at the same time support for applications
00:19:14
using carbon and pr
00:19:16
thus for some time and
00:19:18
lazarus was left without an interface for os x
00:19:21
however thanks to the lazarus team for this is a
00:19:23
fairly short period of time, support for the
00:19:26
rework of which eye of Russia was added
00:19:28
and although it still has some problems, it
00:19:30
works quite stable and the main thing is
00:19:33
now the eye of Russia you can make
00:19:35
truly native applications with a
00:19:37
native interface under os x
00:19:39
and now we’ll finally move on to
00:19:42
installing Lazarus on os x, in
00:19:44
principle there is two ways to install
00:19:46
Lazarus and as with other
00:19:48
operating systems, you can simply
00:19:50
download Lazarus from the official website
00:19:53
before installing Lazarus you will
00:19:56
first need to install the command
00:19:58
line developer tools from apple for this you
00:20:00
will need to run the following
00:20:02
command in the terminal, in principle, if you have developed anything at all
00:20:04
sex, then most likely
00:20:06
you already have the developer tools
00:20:08
installed after this, as in the case of
00:20:11
other operating systems, you will need to
00:20:13
download three packages from the download page
00:20:16
and then install them first on the pc, then
00:20:19
vpc heart and finally lazarus,
00:20:22
but there is another way to install
00:20:25
lazarus which is in in principle, it is also suitable
00:20:27
for other operating systems, just do not
00:20:30
forget about one important detail: you
00:20:31
must choose one
00:20:33
installation method; these methods will conflict at the same time; you
00:20:37
can use the fpt deluxe utility;
00:20:40
before using this utility, you
00:20:43
will need to read the readme for the
00:20:44
necessary dependencies to run it
00:20:47
after that how are the dependencies installed in
00:20:50
this case, these are command
00:20:52
line tools from apple, you can download the utility
00:20:54
from the releases page, you need to take the
00:20:57
latest stable release,
00:20:59
look at this huge list,
00:21:02
this list lists all the architectures
00:21:04
and operating systems on which
00:21:06
Lazarus can be used, as you can
00:21:08
see here there are a huge number of different ones
00:21:10
operating systems, for example, there is
00:21:12
free bsd solaris and even a haiku,
00:21:15
we will, of course, choose Darwin, which is the
00:21:19
only thing worth noting: the utility
00:21:21
cannot be launched from download folders
00:21:23
since the apple operating system does not allow the
00:21:25
application to work normally there.
00:21:29
After launching the utility, you need to make sure that the
00:21:32
PPC of the vertices is up and running. lazarus vertices
00:21:35
is also installed in the steppe, after which you can
00:21:37
safely press the install update button on the pc + the
00:21:40
utility class itself will download the sources of the
00:21:45
free pascal and lazarus compiler, and
00:21:47
literally within a few
00:21:49
minutes we will completely rebuild both the
00:21:51
compiler and the development environment from
00:21:53
scratch, by the way
00:21:54
about the popular myth that firing
00:21:56
Pascal is a slow language, well, as you can
00:22:01
see, the utility has successfully completed its
00:22:03
work and we can launch lazarus
00:22:05
lazarus has started, I have already configured it behind the
00:22:08
scenes and will show you an important setting for os
00:22:12
x you need to go to the parameters and hole find the
00:22:15
debugger tab and turn on the checkbox
00:22:18
reset the debugger after each
00:22:20
launch and also enable the lunch and
00:22:22
new terminal checkboxes so that the console application
00:22:25
works correctly, and just like with
00:22:28
previous operating systems,
00:22:29
let's finalize the standard
00:22:31
application template, put a button on the form and
00:22:35
display the message hello oh sex in its handlers,
00:22:40
launch our application, select
00:22:43
the debugger and how you can see we
00:22:46
got a working native
00:22:48
application,
00:22:50
well, let’s sum up the
00:22:52
previous part of the video with the recommended
00:22:55
settings, and of course, if you
00:22:58
need 1 window mode and it gives it, then
00:23:00
install the appropriate package. I also
00:23:02
highly recommend turning on the display of the
00:23:04
project inspector for fans of the dark theme
00:23:08
in the code editor I recommend turning
00:23:10
it on in the settings, also in the description of the
00:23:12
video I will post my version of the dark theme
00:23:14
for the code editor and for a more
00:23:17
visual appearance of the code I recommend
00:23:19
turning on the display of the block outline, a feature
00:23:21
called smart I would
00:23:23
recommend disabling it because it does not
00:23:25
always work adequately for
00:23:27
Lazarus code completion
00:23:29
uses certain
00:23:30
spacing settings, I recommend these
00:23:33
by default, the eyes of Russia, there is a fairly
00:23:36
large delay before the window is displayed; code
00:23:38
completion of your code, I recommend
00:23:40
reducing it, and finally, I recommend
00:23:43
disabling the checkbox to suggest the name of the new
00:23:45
file in lower case by default; in
00:23:47
my opinion, this will make your project more
00:23:49
readable actually with the help of these
00:23:52
settings you can achieve a very
00:23:53
gentle look of Lazarus on almost
00:23:56
any operating system let's
00:23:58
write some simple programs
00:24:00
in the object pascal language during the writing of
00:24:03
which I will touch a little on the topic of the
00:24:05
syntax of this language I think everyone
00:24:07
understands that by watching one video
00:24:09
on programming you can learn
00:24:11
programming is not allowed, therefore, if
00:24:13
anyone is interested in how to
00:24:15
program for Pascal firing, in the
00:24:17
description of the video I will leave links to
00:24:19
books, courses and various tutorials
00:24:21
on the Pascal firing language. In the future, I
00:24:24
will show everything in the operating system
00:24:26
from Apple,
00:24:27
but you can use your favorite
00:24:28
operating system code will remain the
00:24:30
same, let's start, of course, with the simplest
00:24:32
program called hello world,
00:24:35
which all novice
00:24:36
programmers write, create a new project,
00:24:38
select the project type, a simple program
00:24:41
is created, a template project is created, I recommend
00:24:45
immediately saving the projects, give it an
00:24:48
adequate name, the free pascal compiler
00:24:51
supports many different modes,
00:24:53
I will indicate the mode everywhere Delphi
00:24:55
since the Delphi syntax is the most
00:24:57
familiar to me, as you can see in our project there is a
00:24:59
keyword of programs with the name of the
00:25:01
programs
00:25:02
as well as operator brackets begin and this
00:25:05
is where we will write our code, we
00:25:07
will use the standard
00:25:09
write down operator which allows us to output
00:25:11
various things at the end, for example strings or
00:25:14
numbers we will output line hello world
00:25:18
the program is generally completed, let's
00:25:21
run it oops the
00:25:24
program started and then
00:25:26
ended, maybe there is some kind of error in it, let's
00:25:29
try to run this
00:25:30
program from Explorer and look, it
00:25:33
still starts and
00:25:35
ends immediately, however, if we run from the
00:25:38
terminal as you see, our
00:25:39
program actually works, this is
00:25:42
due to the fact that the program outputs
00:25:44
text to the console and ends immediately, but
00:25:46
by default, the console closes
00:25:49
as soon as the program ends,
00:25:50
and thus we do not see the result of
00:25:52
our program, so then
00:25:54
let's let's finalize our program
00:25:56
using the regilin operator, which
00:25:58
allows you to enter any things into our
00:26:00
program,
00:26:01
or if no parameters are specified, then
00:26:03
it just waits for the enter key to be pressed.
00:26:05
Now we run our program and
00:26:08
as you can see it works fine, let's
00:26:12
write a simple program
00:26:15
using functions, namely
00:26:16
a program that calculates the factorial
00:26:18
videonova for users of the number
00:26:20
the factorial from n is the product of
00:26:23
natural numbers from one to n for
00:26:25
example this is what the factorial of the number 5 looks like
00:26:28
let's create a project and immediately save it
00:26:30
under the appropriate name turn on the delphi mode
00:26:34
by the way you can set the
00:26:37
default mode for the entire project in the global
00:26:38
project settings Now let’s describe a function
00:26:41
that returns the factorial of n. The
00:26:43
functions are defined using the
00:26:45
corresponding keyword, then
00:26:48
the name of the function comes, and in parentheses
00:26:50
the list of parameters that the
00:26:52
function accepts first comes the name of the
00:26:55
parameter and then the type, and the type of the
00:26:57
function’s return value
00:26:58
is indicated after the colon. In this
00:27:01
case, our fact function will accept
00:27:04
and type integer
00:27:06
and return also an integer interjet this is an integer
00:27:08
returned by the function of the
00:27:10
value of the
00:27:11
live pseudo variable cut let's write a
00:27:14
loop that will equate the
00:27:15
variable result result multiplied by the
00:27:19
loop variable in this case this is oh let's
00:27:21
declare a loop variable and set the
00:27:24
initial value result one
00:27:27
so we wrote a function
00:27:29
that returns factorial of the number n
00:27:32
As you can see in Pascal, variables
00:27:34
are declared in a separate block, someone will
00:27:36
say that this is a plus, someone will say that
00:27:38
this is a minus, I personally consider this a plus
00:27:41
since you can always see these changes, you
00:27:42
do not need to scroll through the code of the entire function
00:27:44
or method, this is also a certain
00:27:47
limitation for the size of the function, when
00:27:49
you see that the war block has clearly grown, it
00:27:51
’s worth dividing the function into several.
00:27:53
Now let’s write a code that will
00:27:56
ask the user for the number n and
00:27:58
using the riedel n operator we will
00:28:00
write the variable n the number that the
00:28:03
user entered
00:28:04
further into the res variable, we will save
00:28:07
the result calling the function fact from n well, and
00:28:10
in the end we will display the
00:28:12
variable res with a description that this
00:28:15
will run our program and enter the
00:28:17
number 6 as n the
00:28:19
program has calculated the factorial of 6 it is
00:28:21
equal to 720 and let's check this
00:28:24
using the built-in calculator as you can
00:28:27
see our program modules work correctly;
00:28:29
this is a very powerful tool
00:28:31
that allows you to make the code of your programs
00:28:33
more readable; modules also allow you
00:28:35
to reuse some useful code
00:28:37
in other programs, but in fact, these are
00:28:40
not all the advantages of modules and pascal,
00:28:42
unlike, for example, the advantages of supporting
00:28:44
full-fledged modules, let's rewrite
00:28:47
ours a program for calculating the factorial of a
00:28:49
number for using modules,
00:28:51
select create in the file menu and create a
00:28:54
new module, immediately indicate the
00:28:56
syntax mode that suits us,
00:28:59
and this is Delphi and as we can see, the
00:29:01
development environment has created a module template,
00:29:03
immediately save our module and let's
00:29:06
call it, for example, calc as we We see that the
00:29:09
development environment, using the
00:29:11
uses keyword, has connected other modules to our module,
00:29:14
but our module will be independent of
00:29:16
any modules, so let’s delete these lines. The
00:29:18
module has two sections:
00:29:20
this is the interface, which directly
00:29:22
describes the interface of the module for
00:29:25
programs that use it, and the implementation section,
00:29:29
or in another way the implementation in which the
00:29:30
external code is directly written does
00:29:33
not see the implementation of the module, thus the
00:29:35
principle of
00:29:36
encapsulation is implemented. The idea is that the interface of the
00:29:39
module should remain the same
00:29:41
while we can
00:29:43
safely change the implementation, this will not break any
00:29:45
code, let's copy our fact function
00:29:49
and paste it into the implementation of our module
00:29:52
and in the interface we will describe only
00:29:55
the interface of this function. As you can see, the
00:29:59
development environment has already automatically
00:30:01
connected and our module using the
00:30:02
uses keyword, let's run the
00:30:04
program and make sure that it works and
00:30:07
now the colleagues module can be used in
00:30:10
any other program if we
00:30:12
need it calculate the factorial of a number,
00:30:14
as you can see, if we comment out
00:30:16
the connection of the module, then our program does not
00:30:18
compile, and now a small
00:30:21
demonstration that the implementation section is
00:30:23
really inaccessible to third-party code,
00:30:26
let's rename the function fact to du
00:30:29
fact, as you can see in the interface there is no
00:30:31
description of the function du fact and,
00:30:33
accordingly, third-party code and and can’t
00:30:34
call it’s time to talk about
00:30:37
classes firing pascal
00:30:39
I won’t tell you what a class is
00:30:41
because it will take a lot of
00:30:43
time you can read about it in
00:30:45
books or for example on Wikipedia but
00:30:47
we will write a simple class and play with it a little and
00:30:50
create a new project based on the template
00:30:53
the program will immediately save it under an
00:30:56
adequate name and create a new
00:31:00
module in the interface section, write the
00:31:02
keyword type which allows you to
00:31:05
create new types and create a new
00:31:08
class called direct which will
00:31:10
describe a certain rectangle by
00:31:12
default if you do not specifically indicate
00:31:14
which class our class is inherited from
00:31:17
then it is inherited from the root class t
00:31:20
and g,
00:31:21
but if we really wish, we can indicate
00:31:23
that in principle there is no difference in inheritance from an object;
00:31:25
classes in
00:31:28
Pascal have several scopes of
00:31:29
visibility, this is welcome, here the
00:31:32
private members of the class are described, protected, this
00:31:34
area is accessible by the heir of the class and
00:31:37
public, public members are described here members of the
00:31:40
class there is also a special
00:31:42
public section designed primarily
00:31:44
for the work of reflex or rtt oh, we
00:31:49
will create a public section in which we write
00:31:51
two fields: the width of the rectangle and the height of the
00:31:54
rectangle, we will also create a
00:31:58
class method called calcarea that
00:32:00
allows us to calculate the area of ​​our
00:32:02
rectangle, now we press the magic
00:32:05
combination of shift control buttons ts in order
00:32:08
for the development environment to create
00:32:10
method prototypes, as you can see in the
00:32:13
implementation section, now there is an empty
00:32:15
implementation of the clip aria method,
00:32:17
let's write code that will
00:32:19
return the area of ​​our rectangle
00:32:20
to access directly the object there
00:32:23
is a pseudo variable cells, although often
00:32:26
you don’t have to write it, I’m all- I still recommend
00:32:27
doing this, this way you will
00:32:30
get more readable code. In this
00:32:32
case, we simply return the result of
00:32:34
multiplying the width by height. We will save the
00:32:38
module with our class and write the code
00:32:41
that uses it. We will create a new
00:32:43
procedure called test procedures. It
00:32:45
differs from a function in that it
00:32:48
does not return anything. the main thing is the blocks of
00:32:50
legends we will call this procedure in the
00:32:53
procedure t we will create a variable
00:32:55
called rect which will store
00:32:57
an instance of our class now we will assign to the
00:32:59
rect variable a new instance of our
00:33:01
class an
00:33:02
instance of the class can be obtained
00:33:05
using the constructor the default constructor
00:33:07
is the create constructor
00:33:09
assigning the width and height of our
00:33:12
rectangle some values, let it
00:33:14
be 20 by 5, well, let's write a code that
00:33:17
displays the width of the rectangle, the
00:33:19
height of the rectangle and the area
00:33:22
using the calcarea method, let's run our
00:33:25
program and as you can see, the
00:33:28
area of ​​the rectangle is actually calculated correctly,
00:33:31
but in fact this code is terrible in
00:33:35
it there is a memory leak, let's make sure
00:33:37
of this, go to the parameters of
00:33:40
the project, select the debugging tab and
00:33:43
turn on memory leak tracking,
00:33:47
run our application again and as
00:33:50
you can see after its completion,
00:33:52
we have one memory leak detected, the fact is
00:33:56
that in Pascal firing, like many In
00:33:58
native languages ​​there is no such thing as
00:34:00
garbage collection and objects must be deleted
00:34:03
yourself. You can do this using
00:34:06
ri methods. Let's
00:34:07
run our code again and as you can see there is
00:34:10
no more memory leak, but the cat is
00:34:13
still terrible, let's write a
00:34:16
global exception handler in
00:34:17
which, if an exception occurs, we will print it in the
00:34:20
console to the word exception, this is any
00:34:22
invalid operation, such as
00:34:24
going beyond the limit of an array, division by zero,
00:34:27
and so on, and now in the test procedure,
00:34:30
before calling the free method, let's throw an
00:34:32
exception, let it be the most
00:34:34
ordinary standard exception,
00:34:36
now we run our program, as you
00:34:39
can see the exception really is
00:34:40
worked, a message was displayed in the console
00:34:43
and we had a memory leak, but it’s
00:34:47
quite easy to fix it, the
00:34:48
thrive anna lee construction will help here and
00:34:50
the idea of ​​this construction is that the code in the
00:34:53
finally block will always be executed even
00:34:55
if an exception occurs in the troy block,
00:35:01
run our program again and how
00:35:04
you see there are no more memory leaks,
00:35:06
but the code of our class is also far from
00:35:10
ideal, let's set a negative
00:35:13
height for our rectangle and
00:35:15
run the program and it seems we got a
00:35:20
negative area, I think that
00:35:22
the negative area of ​​a rectangle
00:35:23
is just some kind of nonsense, no, of course I don’t
00:35:26
argue, I’m sure that in some
00:35:28
Lobachevsky geometry this is possible, but
00:35:31
this is definitely not our case, so let's
00:35:33
rewrite our code to use
00:35:36
properties or in another way property,
00:35:38
our idea is that for the external code
00:35:41
the properties will look just like an
00:35:42
ordinary field of the reality class,
00:35:45
depending on then we read is
00:35:47
property or write to property will be
00:35:50
called where
00:35:51
this or setter, respectively, or
00:35:53
one thing depending on what we
00:35:56
want to do, I personally really miss
00:35:58
property in languages ​​​​such as C plus plus
00:36:00
or Golding, let's open the file with our
00:36:04
class again and comment out the width and
00:36:07
height fields and write property instead, I
00:36:10
think you noticed that I didn’t write the center
00:36:12
and the getter, in fact, I can arrange
00:36:15
only one setter and Lazarus can
00:36:18
create setter templates for this, I
00:36:20
press the magic key combination
00:36:22
shift kontrol c
00:36:24
as you see it appeared section leads
00:36:27
in which we have the same fields
00:36:29
that were before this current with the prefix f,
00:36:32
also two methods have appeared for setting the
00:36:34
height and setting the width: reading
00:36:37
occurs directly from the fields
00:36:39
and writing occurs through setters by
00:36:42
default, these methods essentially
00:36:44
do nothing special let's change the method for
00:36:47
setting the height, if the new
00:36:49
height value is greater than zero, then we'll assign
00:36:53
this value to the f field, otherwise we'll
00:36:57
assign it to the f50 field,
00:37:00
this way we get rid of the
00:37:02
ability to set a negative
00:37:04
height, we do the same thing and for
00:37:06
the width we run the project and as you can see
00:37:12
we no longer we can set a
00:37:14
negative height and, accordingly,
00:37:16
we also will not have a negative area, the
00:37:19
area is equal to zero for a height equal to
00:37:21
zero, and note that the code that
00:37:24
used the class did not
00:37:25
have to be rewritten, that is, syntactically, that
00:37:28
the properties that flight are equivalent for the external code
00:37:31
and finally let’s move on to the
00:37:34
most interesting part my opinion,
00:37:36
namely to create windowed applications from the
00:37:38
eye of Russia, let's create a new project and
00:37:42
select applications as a template; an
00:37:45
empty application with a
00:37:47
graphical user interface has been created and
00:37:49
let's immediately look at the windows and gives
00:37:52
which are visible on the screen above the
00:37:55
code editor, visible editable and the form in
00:37:57
which the design is carried out
00:37:59
the interface on part of your application
00:38:01
does not switch between the code and the
00:38:03
form designer, you can use the
00:38:05
appropriate menu or hotkey at the
00:38:09
top of the main window there is a
00:38:11
palette of components of the
00:38:13
Eye of Russia, there are a lot of built-in
00:38:14
components, but today we will
00:38:17
only use the components that
00:38:19
are located on the standard tab on the left
00:38:22
side there is an inspector objects in
00:38:25
which you can change the properties of both the
00:38:27
form and the components located on it and
00:38:29
on top of the
00:38:30
object inspector there is a tree of
00:38:33
components of the current form on the right side
00:38:36
there is a code inspector window this
00:38:39
window allows you to quickly analyze
00:38:41
your code there is also a
00:38:44
project inspector window in which the
00:38:46
file tree is displayed of your
00:38:47
project,
00:38:48
and at the bottom there is an output window,
00:38:51
including messages from compilers. As a
00:38:54
simple example of a windowed application,
00:38:56
I propose to make an application that
00:38:58
will greet the user by the
00:39:00
name he entered. Let’s save our project by clicking the
00:39:03
save all icon, enter the project name,
00:39:06
let it be hello
00:39:07
lpl, now save the module with the form I I’ll
00:39:11
call it the unit main our unity form is
00:39:14
presented as a class t form1
00:39:16
inherited from the class t forms which is a
00:39:19
standard class for the forms of the eye of Russia
00:39:21
so that it doesn’t hurt later, I advise you
00:39:24
to give your forms and components
00:39:26
clear names, let’s rename the
00:39:29
name of the form to forms main
00:39:32
which corresponds to the name of our module
00:39:34
as you can see in the code, everything has also
00:39:36
automatically renamed the axis of a
00:39:38
specific instance of the form that
00:39:40
opens when the application starts,
00:39:42
represented by the global form variable
00:39:45
main, you should not be afraid of global
00:39:47
variables for the main form, there
00:39:51
should be some kind of global variable in the application in any case. Moreover, with
00:39:53
experience you will learn to get rid of of such
00:39:55
global variables,
00:39:57
now it’s time to place a component on the form
00:39:59
and place the component on the form
00:40:01
you label is a label that displays
00:40:04
text, immediately rename it to the name label
00:40:07
and as the title med we
00:40:09
enter the line name with a colon as you can
00:40:13
see in the design of the reforms the change
00:40:15
immediately came into effect force into the next component
00:40:18
that we will place on the form,
00:40:19
this is the input field you are coming, I will immediately
00:40:22
set the input field to some
00:40:24
adequate size and the last component
00:40:26
that we will place on the forum is this button, we are
00:40:28
replacing the text of the input field with the
00:40:32
line user and renaming the
00:40:35
component itself,
00:40:36
let's call it going name we
00:40:39
also rename the button to baton ok and lastly we
00:40:42
change the title of the button to ok
00:40:45
and as we can see, the
00:40:48
corresponding fields were automatically added to the form class,
00:40:51
double-click on the button to
00:40:53
create a default event handler, the
00:40:55
default event handler is
00:40:58
clicked, however, you can create handlers in the
00:41:01
object inspector and other events,
00:41:03
for example, the movement of the mouse cursor over the
00:41:05
component receiving input focus or
00:41:07
pressing a key on the keyboard, we will add to the
00:41:11
method for processing the button press
00:41:12
a
00:41:18
variable name that will store the text entered by the user; we will assign the variable name to the text from the input field
00:41:21
y-components you go to the
00:41:23
text entered by the user to store the properties of the
00:41:25
text after that how we
00:41:28
got the text entered by the user in the name variable, we
00:41:29
will display the message hello on the screen with
00:41:32
a space and the entered text,
00:41:35
you can join lines in pascal
00:41:38
using the plus sign, we launch our application
00:41:42
and get a compilation error because
00:41:45
I forgot to enable the dlc mode,
00:41:47
we turn on Jim Dolphin and run it
00:41:50
again our application has started and we
00:41:54
can enter the name at as a name in
00:41:57
view of YouTube, click on the ok button and a
00:42:00
greeting to YouTube appears in the pop-up window,
00:42:02
so it’s easy and simple
00:42:05
to create Lazarus and window applications, I
00:42:08
suggest you dive a little deeper
00:42:10
and see how a
00:42:12
window application actually works and before
00:42:15
before we continue with a small announcement,
00:42:17
not friends, in this difficult time, I and
00:42:20
my channel desperately need your
00:42:23
financial support, if you have
00:42:25
such an opportunity, then subscribe to me
00:42:28
on the patreon service to
00:42:31
donate a certain amount of money for 1 month for the
00:42:33
development of the channel, you can also
00:42:36
donate through this service,
00:42:38
alerts links will be in the description expressing
00:42:41
gratitude to those who are already subscribed to
00:42:43
my patreon
00:42:44
and also to donors from streams, stop, you
00:42:47
don’t know that I am doing streams
00:42:48
then be sure to subscribe to my
00:42:51
telegram channel so as not to miss new ones
00:42:53
when you edit the form in The designer
00:42:56
actually edits the native
00:42:58
window of the operating system, place the
00:43:01
native controls and operating
00:43:03
system in this window while saving the same form due to the
00:43:06
powerful
00:43:08
rt mechanism or reflex, everything is implemented in a
00:43:11
text form, you can see the
00:43:14
text representation of the form by clicking on
00:43:16
it with the left mouse button and selecting
00:43:18
show the
00:43:19
source text text format for storing
00:43:22
forms is somewhat reminiscent of the currently popular
00:43:25
Jason format, although
00:43:27
this format appeared much earlier with the extension Elf
00:43:30
Vine of Russia
00:43:31
or dfm in Delphi also has a tree
00:43:34
structure as you can see we
00:43:37
have a root object in this case this is
00:43:39
our forms in which there are
00:43:42
components that we placed on
00:43:44
this form, all the properties that we
00:43:46
edited for these components
00:43:48
are reflected in text form,
00:43:50
in principle, no one can prevent us from
00:43:53
editing the form not in Rio design in
00:43:55
text view, let's change the
00:43:57
title of the form, replace the title with the
00:44:00
name of the channel and save the file now
00:44:03
menu view, select switch form
00:44:06
module and our Odessa form is implemented from a
00:44:08
text view into a real
00:44:10
window. As you can see, the title
00:44:12
has actually changed
00:44:14
accordingly. The forms in your application
00:44:16
are stored in exactly this text form, and
00:44:19
when the application starts
00:44:20
or if we manually create a form, children
00:44:23
are implemented from a text view into a
00:44:25
real window. By the way, it’s an interesting fact
00:44:28
because the advantage is that there is no full-fledged
00:44:30
reflex when you morgue, you have to
00:44:32
run C plus plus in front of a real compiler.
00:44:35
Hello, a compiler that
00:44:38
simulates reflection naturally does
00:44:40
not work as well as real
00:44:42
reflex, and this is another disadvantage of C
00:44:44
plus plus for me personally in the language
00:44:47
they add all sorts of battleship
00:44:49
operators complex numbers to the standards
00:44:52
but do not add those things that
00:44:53
developers really need,
00:44:55
such as reflection or full-fledged
00:44:58
modules.
00:44:59
Another important knowledge is
00:45:02
understanding the work of windowed applications in
00:45:04
all operating systems.
00:45:06
I think you noticed that, unlike
00:45:08
console applications, where the thread of
00:45:09
execution is in your hands and your code
00:45:12
calls something in windowed applications
00:45:15
lpl owns the thread of execution and
00:45:17
calls your code when
00:45:19
some events occur such as pressing a button
00:45:22
let's open the main project file and
00:45:25
look at its structure as you can
00:45:28
see first we initialize the
00:45:30
application object we create the necessary
00:45:32
forms and finally launch our
00:45:35
application, I made an approximate
00:45:37
flowchart of how it actually
00:45:39
works after the
00:45:41
armorer zero application has been created and created the
00:45:43
necessary forms, the vast majority of the time it
00:45:46
does nothing and only waits for a
00:45:48
message from the operating system
00:45:50
when the user, for example, presses a
00:45:53
button and does not perform another action with
00:45:55
your application,
00:45:56
then the operating system returns the
00:45:59
lpl library the code of this message,
00:46:01
then the lpl library creates events in the
00:46:04
form we are familiar with and calls your
00:46:07
user code after your
00:46:09
code has worked, we return to the main
00:46:11
loop and wait for a new message from the
00:46:14
operating system this loop will
00:46:16
run indefinitely until the operating
00:46:18
system sends your application
00:46:20
a message about the need to shut down,
00:46:22
after which
00:46:24
resources are released and applications shut down.
00:46:28
At the same time, the operating system really doesn’t
00:46:31
like it when your application
00:46:33
does not receive new messages for too long
00:46:35
after the
00:46:37
operating system’s message buffer is full or
00:46:40
Quite a long time will pass during
00:46:42
which the application does not process a new
00:46:44
message from the operating system, then the
00:46:46
operating system will assume that
00:46:48
the application is simply frozen offering
00:46:52
such a small example here on the
00:46:54
form there are 2 buttons, a button with the
00:46:57
inscription slip makes your application
00:46:58
fall asleep for one minute functions slip 2
00:47:02
button with the inscription test does nothing
00:47:04
and is only needed for indication,
00:47:06
let's launch our application and
00:47:09
click on the test button,
00:47:10
as you can see the test button
00:47:13
is pressed perfectly, also the application quietly
00:47:16
changes the window size, now let's click on the
00:47:18
button that will make our application
00:47:20
fall asleep for 60 seconds, let's try to change
00:47:23
window size by clicking on the test button and
00:47:26
even closing our application. As you
00:47:28
can see, the application does not react in any way
00:47:30
to the user’s actions from the
00:47:32
user’s point of view, it just
00:47:34
froze after some time, the
00:47:36
operating system also comes to
00:47:38
this conclusion and all we can do
00:47:41
is wait 60 seconds or
00:47:43
forcefully terminate applications from
00:47:46
all this we can conclude that the
00:47:47
event handlers in your application
00:47:49
should complete as soon as possible, but if
00:47:53
you need to perform some
00:47:55
long-running operations, then at least change the
00:47:57
rates to an hourglass or, what is much
00:48:00
more correct, make a separate thread
00:48:03
so as not to block the main thread of
00:48:04
your application, but keep in mind that the
00:48:07
graphical user interface is
00:48:08
exclusively single-threaded and you
00:48:11
need to update it from the main thread, otherwise you
00:48:13
will encounter incredible glitches.
00:48:18
The application we made before
00:48:20
has, to put it mildly, a terrible interface; it is
00:48:23
absolutely not scalable; when the
00:48:25
window size is changed, the
00:48:27
control retains its size and
00:48:29
position and the application looks broken,
00:48:32
in addition, we can absurdly
00:48:34
reduce the size of the window, but Lazarus of
00:48:37
course has the ability to make a good
00:48:39
scalable interface as an
00:48:41
example, let's repeat the Vine of Russia, here is
00:48:43
such a simple layout, this is a window with the
00:48:45
cancel
00:48:47
and ok buttons at the bottom and the rest of the area takes up a
00:48:50
multi-line text editor I
00:48:52
drew a more detailed version of the layouts
00:48:54
which indicated the necessary indents and
00:48:57
also signed the components that we
00:48:59
will use to reproduce
00:49:00
this interface create a new project and
00:49:04
immediately save it
00:49:06
and of course do not forget to rename the
00:49:08
form now we place the component on the form
00:49:13
you are past
00:49:14
this is a multi-line text editor and a
00:49:16
panel in which the buttons will be located,
00:49:19
we rename both components, we remove
00:49:25
the inscription from the panel and turn off the border. As you can
00:49:29
see, the panel has become invisible, the align properties
00:49:32
or the alignment of the panel
00:49:34
is set to bot, this means that
00:49:37
the panel will remain at the bottom of the window
00:49:39
while changing its width to the size of
00:49:41
this window, the height will remain
00:49:43
unchanged and the align properties of the
00:49:46
past component will be set in the client, which will make the
00:49:48
component expand to the entire available
00:49:50
size of these actions enough for the
00:49:53
text editor and the panel to begin to
00:49:55
scale to the size of the window. Now let's
00:49:57
open the editor; you can bind the past component by
00:49:59
right-
00:50:01
clicking mouse over it and selecting the
00:50:03
anchor editor in the pop-up menu, we
00:50:06
will set the indents in accordance with the
00:50:08
layout, this is an indent on the top left and
00:50:10
right of six pixels,
00:50:12
the changes immediately took effect in the
00:50:14
designer, now we will put two buttons on the panel
00:50:17
and
00:50:19
finally give them adequate names, open the
00:50:24
anchor editor button ok
00:50:27
since the button will be located on the
00:50:29
right side, disable the left anchor
00:50:33
as a neighbor for the top anchor the
00:50:35
panel on which the button lies is installed
00:50:36
and set the alignment to the
00:50:39
center so the button will be
00:50:40
located in the middle vertically
00:50:42
now turn on the right anchor select the
00:50:45
anchor on the right as a neighbor
00:50:48
we will also select panel as you see, the button
00:50:50
is now in the middle vertically
00:50:52
and is anchored to the right side of the panel.
00:50:56
We will do the same for the
00:50:58
cancel button with the only difference: the
00:51:01
neighbor for the right anchor will be the ok button
00:51:04
and the anchor will be to the left side of this
00:51:06
button so that the components are located on the
00:51:10
panel had a certain distance between each
00:51:12
other, use the child
00:51:14
sizing property and set it under the horizontal
00:51:16
spacing properties to 4
00:51:18
in accordance with the layout. As you can see, there
00:51:21
is now a distance between the buttons, but
00:51:24
in order for the ok button not to stick to the
00:51:26
left side of the panel, use the
00:51:28
border vis property and set it to 6
00:51:31
how on the layout it
00:51:32
remains to choose the appropriate height of the
00:51:34
panel, let's launch this application.
00:51:38
As you can see, the application interface is
00:51:40
correctly scaled to change the
00:51:42
window;
00:51:44
however, we can still reduce the size of the
00:51:46
window, but not within reasonable limits; the constraint property
00:51:49
is responsible for limiting the size of the form;
00:51:53
let's set the minimum height to
00:51:55
200 and the minimum the width is 3 cm and also
00:51:58
in order for the height of the panel to be
00:52:00
adjusted to the size of the buttons,
00:52:01
which can be different for different
00:52:03
operating systems, we will set the properties of the
00:52:06
auto says panel to true,
00:52:07
now you cannot manually change the height of the panel,
00:52:10
but it fits perfectly to the
00:52:12
size of the buttons, and the last thing we
00:52:15
will do is change the headings of the
00:52:17
components so that they fully
00:52:19
correspond to the heading in the layout, we
00:52:21
launch the application again and as you can
00:52:25
see, we cannot reduce the window size to
00:52:27
less than what we installed,
00:52:29
we got a native application with a
00:52:32
native interface in which
00:52:34
all the features of the
00:52:35
operating system work, for example, in the case of
00:52:38
MacOS it is the ability to change the register
00:52:40
of all the selected characters, compare this with an
00:52:44
application written by cape and in which the
00:52:46
interface is drawn independently
00:52:48
and of course there are not all the features of the operating
00:52:51
system, I copied this project on
00:52:54
Windows, launched it and as you can
00:52:56
see, under Windows we get a
00:52:58
beautiful native interface, I will not
00:53:01
deprive the operating system of attention the
00:53:03
linux system in this case is
00:53:05
manjari linux in which our application
00:53:07
also looks adequate debugging is an
00:53:12
important part of the development of any
00:53:14
application and now I will talk a little
00:53:16
about debugging the eyes of Russia
00:53:19
Lazarus to debug applications they
00:53:21
use the gdb debugger I think that you have
00:53:24
already encountered it,
00:53:26
I wrote from such Here is a simple code
00:53:28
that, when you press a button in a loop,
00:53:31
adds a line of numbers from 0 to 9 and
00:53:34
then displays a message with the resulting line.
00:53:37
Before debugging the application,
00:53:40
let's make sure in the parameters that the
00:53:42
necessary settings are set,
00:53:45
namely, the checkbox should be checked to
00:53:46
reset the debugger after each
00:53:48
launch also, for the debugger to
00:53:51
work correctly in the project parameters, the
00:53:53
optimization level must be set to the
00:53:55
minimum level,
00:53:57
set a breakpoint on the fortieth
00:54:00
line of this loop body and run the project,
00:54:04
click on the button and as you can
00:54:07
see in lazarus, paused the execution of the
00:54:09
code at the breakpoints, you can
00:54:12
hover over the variable and see what is
00:54:15
currently stored in it and use the
00:54:17
appropriate buttons to perform
00:54:19
step-by-step debugging of your programs. We have gone
00:54:21
through several steps and can once again
00:54:23
look at the values ​​of the variables
00:54:25
they have changed. You can also open an
00:54:28
additional debugging window, for example, the
00:54:31
local variables window.
00:54:32
Now with further debugging you can
00:54:34
constantly see the values ​​that
00:54:36
are stored in these variables
00:54:37
under all other operating
00:54:39
systems except OS X
00:54:41
and the scarf looks exactly the same, but
00:54:44
your sex is getting more and more complicated, the thing is that
00:54:46
Apple did everything so that the gdb debugger
00:54:49
stopped working normally on this
00:54:51
operating system, there are whole threads
00:54:54
on some sites on how to fix the
00:54:55
debugger gdb since the gdb debugger
00:54:58
is used in a bunch of different
00:55:00
development environments, but to be honest, I
00:55:03
couldn’t fix gdb on OS X. The
00:55:05
Lazarus and freepascal team, seeing this
00:55:08
problem,
00:55:09
added support for the ll db debugger,
00:55:11
which is in alpha mode. The
00:55:14
debugger is not very
00:55:16
stable now. but it's better than nothing in the
00:55:19
parameters, etc. we need to make sure that
00:55:20
this debugger is really there,
00:55:23
let's run the same application
00:55:26
and set a breakpoint,
00:55:29
now we click on the button and when we
00:55:32
hover over a variable, we don't see its
00:55:34
value, the debugger crashes, however, the
00:55:38
window of local variables is completely working,
00:55:41
besides, no one canceled debugging
00:55:44
using outputs terminal,
00:55:46
and the last one, I’ll tell you how to make the
00:55:49
final build of your application. At
00:55:52
one time, Lazarus was very much criticized
00:55:54
for the size of the resulting application, although
00:55:57
now in 2020 it all looks funny
00:56:00
in a world where applications made on an
00:56:02
electron weigh hundreds of megabytes, as you can
00:56:06
see, our application weighs as much as 20 4
00:56:09
megabyte since it contains debugging
00:56:12
information, let's reduce the size of the
00:56:14
application, go to the settings of our
00:56:17
project and create a new build mode, it
00:56:22
immediately becomes the active mode,
00:56:24
let's call it release in this mode,
00:56:28
disable the generation of debugging information
00:56:31
and enable optimization level 3, and if
00:56:35
the size is very important, then you can
00:56:37
install tick the priority of size over
00:56:40
speed, make sure that the configuration
00:56:43
we have now is really worth the release and
00:56:45
launch the application. Now let's look at the
00:56:48
size of the resulting exe file. As you
00:56:51
can see, the size of the application is now
00:56:53
only 3 megabytes and this application
00:56:56
does not depend on any additional
00:56:58
libraries, you can safely share it with
00:57:01
your friends and it will work
00:57:03
on almost every system starting from
00:57:05
windows 7 under linux in general all the same
00:57:08
lazarus is trying to make
00:57:12
binaries that are as independent from the environment as possible I asked several friends
00:57:15
to test this application and it
00:57:17
worked great on ubuntu
00:57:20
noman heat linux style for you as a window
00:57:23
manager and even on chrome os from google
00:57:26
on an operating system from apple the
00:57:29
application is usually distributed in an
00:57:31
application bundle so let's go to the
00:57:34
project parameters,
00:57:35
open the application tab and click on the
00:57:38
button create an
00:57:39
application bundle compile the application
00:57:42
and as we see we have two files the
00:57:44
direct
00:57:45
executable file and the application in
00:57:48
was by default in the Windows application there
00:57:50
is a symbolic link to the
00:57:53
executable file in order to
00:57:55
place the
00:57:56
executable file directly inside you
00:57:58
need to copy the application band to a
00:58:00
separate folder open it using the
00:58:02
option show package contents open the
00:58:05
mac os folder and replace the symbolic one
00:58:08
a link directly to the executable
00:58:10
file, that’s all, we have received applications ready for
00:58:13
distribution for the
00:58:15
iOS x operating system,
00:58:17
this video has come to an end,
00:58:21
thank you for watching it to the end, all the
00:58:24
projects that I showed in this
00:58:26
video, I will, of course, post it on my beat
00:58:28
hop and leave it there is a link in the description if this is your
00:58:31
first time on my channel, be sure to
00:58:33
subscribe to it, there will be
00:58:35
a lot more interesting things and don’t forget to
00:58:37
click on the bell,
00:58:39
insert likes into this video,
00:58:41
repost this video on your social networks,
00:58:43
write comments by the way, the code word
00:58:46
for this video is pascal, write a
00:58:48
comment that contains this word is
00:58:50
exactly how I know that you
00:58:52
watched this video to the end and of
00:58:55
course don’t forget that I and my channel
00:58:58
desperately need your financial support,
00:59:01
if you have such an opportunity, then
00:59:03
subscribe to my patreon to
00:59:06
donate some amount to the channel for 1 month or for
00:59:09
donatti through the service this tire alerts
00:59:11
links will be in the description and with you as
00:59:14
always there was a flood of everything good luck bye
00:59:21
[music]

Description:

✅ Донат: https://www.donationalerts.com/r/crazzzypeter ✅ Patreon (помощь раз в месяц): https://www.patreon.com/crazzzypeter В этом видео я расскажу о настоящей кроссплатформенной разработке с использованием среды Lazarus и языка ObjectPascal. Я советую посмотреть этот ролик всем, вне зависимости от того любите вы этот язык или нет. Я вас уверяю - вы можете найти для себя данную среду действительно крайне полезной. Кроме того мои дальнейшие ролики о программировании будут строиться на этом видео. Также в этом ролике я отвечу на вопросы: - Паскаль мертв? - Паскаль жив? - Что не так с C++? (на мой взгляд) - Что происходит с Qt? - Что происходит с GTK+? ⚫ Проекты из этого видео: https://github.com/turborium/ProgrammingWithLazarus ⚫ Книги по Lazarus: Современный паскаль: https://castle-engine.io/modern_pascal_introduction_russian.pdf Официальные руководства, на русском: http://www.lazarus-doc.h1n.ru/ Книга от Alt Linux: https://docs.altlinux.org/books/freepascal.pdf Экспресс курс программирования в Lazarus: http://popovevgeniy.000webhostapp.com/download/technical/Lazarus.zip Книга про FPC: http://oleg.derevenets.com/Files/Songs/Pesni_o_Paskale_12-11_2018-02-09.pdf Основы программирования в среде Lazarus: http://www.freepascal.ru/download/book/lazarus_osnovy/osnovy_programmirovanija_v_srede_lazarus.pdf ⚫ Пособия по работе с Lazarus: Введение для новичков в Lazarus и Pascal: https://wiki.freepascal.org/Basic_Pascal_Introduction/ru Еще одно введение: https://wiki.freepascal.org/Lazarus_Tutorial/ru Инструкция по установке: https://wiki.freepascal.org/Installing_Lazarus/ru ⚫ Курсы по Pascal: Бесплатный курс от Intuit: https://intuit.ru/studies/courses/13745/1221/info Бесплатный курс от Intuit (основы Pascal): https://intuit.ru/studies/courses/41/41/info Программирование на Lazarus (Intuit): http://intuit.valrkl.ru/course-1265/ Бесплатный курс Stepik про PascalABC.net: https://stepik.org/course/3352/promo Курс от udemy(Англ.): https://www.udemy.com/course/learn-to-program-with-pascal/ Курс от udemy(Англ.): https://www.udemy.com/topic/pascal-programming-language/ Графика в PascalABC: http://staff.mmcs.sfedu.ru/~ulysses/Edu/CS101/PABC_Graph.pdf ⚫ Тебе понравился или нет ролик? - Напиши, что именно в комментариях. ⚫ Темы, затрагиваемые в этом ролике: Программирование, Паскаль, Pascal, Delphi, Lazarus, Windows, Linux, OSX, Разработка, Программирование для начинающих, GUI, Окна, Компоненты, Интерфейс, UI, Нативный код, Компилятор, Отладка, Релиз, Окно, ОС.

Preparing download options

popular icon
Popular
hd icon
HD video
audio icon
Only sound
total icon
All
* — If the video is playing in a new tab, go to it, then right-click on the video and select "Save video as..."
** — Link intended for online playback in specialized players

Questions about downloading video

mobile menu iconHow can I download "Кроссплатформенная разработка с Lazarus/ObjectPascal/Delphi. Программирование #ityoutubersru" video?mobile menu icon

  • http://unidownloader.com/ website is the best way to download a video or a separate audio track if you want to do without installing programs and extensions.

  • The UDL Helper extension is a convenient button that is seamlessly integrated into YouTube, Instagram and OK.ru sites for fast content download.

  • UDL Client program (for Windows) is the most powerful solution that supports more than 900 websites, social networks and video hosting sites, as well as any video quality that is available in the source.

  • UDL Lite is a really convenient way to access a website from your mobile device. With its help, you can easily download videos directly to your smartphone.

mobile menu iconWhich format of "Кроссплатформенная разработка с Lazarus/ObjectPascal/Delphi. Программирование #ityoutubersru" video should I choose?mobile menu icon

  • The best quality formats are FullHD (1080p), 2K (1440p), 4K (2160p) and 8K (4320p). The higher the resolution of your screen, the higher the video quality should be. However, there are other factors to consider: download speed, amount of free space, and device performance during playback.

mobile menu iconWhy does my computer freeze when loading a "Кроссплатформенная разработка с Lazarus/ObjectPascal/Delphi. Программирование #ityoutubersru" video?mobile menu icon

  • The browser/computer should not freeze completely! If this happens, please report it with a link to the video. Sometimes videos cannot be downloaded directly in a suitable format, so we have added the ability to convert the file to the desired format. In some cases, this process may actively use computer resources.

mobile menu iconHow can I download "Кроссплатформенная разработка с Lazarus/ObjectPascal/Delphi. Программирование #ityoutubersru" video to my phone?mobile menu icon

  • You can download a video to your smartphone using the website or the PWA application UDL Lite. It is also possible to send a download link via QR code using the UDL Helper extension.

mobile menu iconHow can I download an audio track (music) to MP3 "Кроссплатформенная разработка с Lazarus/ObjectPascal/Delphi. Программирование #ityoutubersru"?mobile menu icon

  • The most convenient way is to use the UDL Client program, which supports converting video to MP3 format. In some cases, MP3 can also be downloaded through the UDL Helper extension.

mobile menu iconHow can I save a frame from a video "Кроссплатформенная разработка с Lazarus/ObjectPascal/Delphi. Программирование #ityoutubersru"?mobile menu icon

  • This feature is available in the UDL Helper extension. Make sure that "Show the video snapshot button" is checked in the settings. A camera icon should appear in the lower right corner of the player to the left of the "Settings" icon. When you click on it, the current frame from the video will be saved to your computer in JPEG format.

mobile menu iconWhat's the price of all this stuff?mobile menu icon

  • It costs nothing. Our services are absolutely free for all users. There are no PRO subscriptions, no restrictions on the number or maximum length of downloaded videos.