Presentation on the topic: DELPHI programming environment. Presentation on the topic "Basics of working in the Delphi environment" Presentation on the topic Delphi programming language

Description of the presentation by individual slides:

1 slide

Slide description:

Lesson 4 Input/output operations Aleksey Konstantinovich Novikov Lecturer, SPK MSUPE Programming in Delphi

2 slide

Slide description:

Features of files: When created, each file is given a name by which the program processing it can distinguish one file from another. One program can work with several files simultaneously. The file contains elements of only one type or the type of its components is not specified. The length of a file is the number of its elements. When creating a file, the file length is not specified in advance and is limited only by the capacity of the external memory devices.

3 slide

Slide description:

Types of files in Pascal There are three types of files in Pascal: a text file (defined by type text); typed file (specified by the file of Type clause); untyped file (defined by the file type).

4 slide

Slide description:

Description of the file variable typeTypeName1=text; TypeName2=file of Type; TypeName3= file; VarVariableName1:TypeName1; VariableName2: TypeName2; VariableName3: TypeName3;

5 slide

Slide description:

or VarVariableName1= text; VariableName2=file of; VariableName3=file; For example: type fak= text; file type var a, b, x: fak, file variables or var a, x: text; with: file;

6 slide

Slide description:

Types of files A sequential file is a file whose elements are accessed in the same sequence in which they were written. For such files, it is prohibited to simultaneously read and write data to the file. A direct access file is a file whose elements are accessed by address (number). When searching for the desired element, it is enough to indicate its position number, which significantly speeds up the search. Direct access files allow simultaneous writing and reading of data.

7 slide

Slide description:

Operations when working with files When working with files, the program must perform the following operations: open the file; read file; close the file.

8 slide

Slide description:

Procedures and functions applicable to files of any type AssignFile; Reset; Rewrite; Close; Rename; erase; Ioresult; Eof.

Slide 9

Slide description:

Procedure AssignFile In order for a program to output data to a file or read data from a file, it is necessary to specify a specific file, that is, associate a file variable with a specific file. The description of the AssignFile procedure is as follows: AssignFile (FileVariable, FileName); The file name must be a string expression.

10 slide

Slide description:

Examples: AssignFile(f, 'a:\result.txt'); AssignFile (f, 'c:\students\ivanov\korni.txt'); fname: =(‘otchet.txt’); AssignFile(f, fname);

11 slide

Slide description:

The reset procedure The reset procedure opens a file for input (reading) and places a pointer to the beginning of the first element of the file. If, when reading a file, it becomes necessary to return the pointer to its beginning, it will be enough to simply apply the reset procedure to this file again. Reset(FileVariable); For example: AssignFile(f, 'c:\data.txt'); Reset(f); A file variable must be associated with a specific file. If there is no external file with a specified name, an error message appears.

12 slide

Slide description:

rewrite procedure The rewrite procedure (FileVariable) creates and opens a new file for the next data entry. After its successful execution, the file is ready to write the first element to it. Note! If an external file with the specified name already exists, it is deleted and a new one is created in its place. empty file with the same name. To prevent information loss in practice, it is necessary to create backups files (usually given the extension bak).

Slide 13

Slide description:

Procedure Close Procedure Close(FileVariable); Allows you to close a file after the program has completed processing it. IN otherwise Data loss may occur. When closed, the external file is updated and automatically terminated by an end-of-file character.

Slide 14

Slide description:

The rename procedure The rename procedure (FileVariable, FileName) is used to rename an unopened external file of any type. The new name is specified by the FileName line.

15 slide

Slide description:

The erase procedure The erase procedure (FileVariable) deletes an unopened external file of any type specified by the FileVariable parameter. Note! The rename and erase procedures cannot be used on open files.

16 slide

Slide description:

The ioresult function The ioresult function checks the existence of a file on disk. As a rule, this is done automatically, but sometimes there is a need to use this function.

Slide 17

Slide description:

Function eof The logical function eof (File Variable) checks whether the End Of File has been reached when reading data from it. The function returns true if the end of the file is detected and the current position pointer is at the end of the file after its last character. This means that the last element in the file has already been read, or the file was empty after opening. Otherwise the function executes false.

18 slide

Slide description:

Text File A text file is a sequence of char characters grouped into lines ending special character end. At the end of any file, including text, the symbol #26 (SUB) is placed - the end of the file eof. Declaring text files in the program looks like this: Type TypeName = text; var FileVariable: TypeName; or var FileVariable: Text File; File Variable – the name of the file variable.

Slide 19

Slide description:

Procedures and functions for text files. The Append procedure (FileVariable) opens existing file for additional recording - applicable only for text files. The pointer becomes at the end of the file, where new components will be added. The File Variable must be associated with external file using the assign procedure. If the file was previously opened using reset or rewrite, using append will close the file and reopen it for appending.

20 slide

Slide description:

Procedures write, writeln Output to a text file is carried out using the procedures write, writeln. The write procedure instruction looks like this: write (FileVariable, y1, y2, ..., yN); writeln(FileVariable, y1, ..., yN); writeln(FileVar); where y1, y2, ..., yN is the output list, that is, the names of variables whose values ​​need to be output to the file, starting from the position of the current pointer. The output list contains the expressions to be printed different types(integer, real, char, string, boolean). The file must be open for output.

21 slides

Slide description:

Procedures read, readln Reading from a file is performed using read and readln. Read procedure read(FileVariable x1, x2, ..., xN); readln(FileVariable x1, x2, ..., xN); readln(FileVariable); x1, x2, ..., xN – an input list containing names of variables of different types (integer, real, char, string), the values ​​of which the read procedure reads from a text file, starting reading from the element to which the current pointer is set. FileVariable is of type text.

22 slide

Slide description:

Example For example, if the text file a:\ data.txt contains the following lines: 23 15 45 28 56 71 then as a result of executing the instructions: Assignfile (f, 'a:\ data.txt'); Reset(f); // opening for reading read (f, a); read(f, b, c.); read(f, d); the values ​​of the variables will be a=23, b=15, c=45, d=28,

Slide 23

Slide description:

and as a result of executing the instructions: Assignfile (f, 'a:\data.txt'); Reset(f); // opening for reading readln (f, a); readln(f, b. c); readln (f, d) the values ​​of the variables will be a=23; b=45; c=28; d=56.

24 slide

Slide description:

eoln Function To control the end of a line, the eoln (File Variable) function is used, which takes true if the current position indicator is at the end of line marker (CR/LF), otherwise - false. If eof is true, then eoln is true.

25 slide

Slide description:

Options for choosing a buffer variable: An array or linked list of strings into which the entire file will be read at once; One variable of string type into which lines of the file will be read one by one; One variable character type, into which characters will be read one by one.

26 slide

Slide description:

Typed files A typed file consists of a sequence of elements of the same type and length. Their number and, therefore, the file size is not limited when specifying it. Each file element has a number. The first element is considered to be zero. At any given time, only one element is available to the program - the current element to which the file pointer is set. Since all elements of a file are the same length, the position of each element is easily calculated. Therefore, the pointer can be moved to any element of the file, providing direct access to it.

Slide 27

Slide description:

Declaration of typed files Type TypeName = file of Type Var FileVariable: TypeName; Or Var FileVariable = file of Type;

28 slide

Slide description:

When processing such files, some additional procedures and functions may be used; a number of common ones known to us have their own characteristics. You can open a typed file using standard methods: reset and rewrite. Something to know: Typed and untyped files are always both read and writeable, regardless of whether they were opened with reset or rewrite; To read and write a typed file, only the reset or write procedures are used. The use of readln and writeln is prohibited.

programming using one of the most common rapid application development systems - Delphi Using this training course, you can independently master the basics of object-oriented programming in Delphi. To expand your knowledge, a number of teaching aids and reference books on Delphi The cycle contains 13 presentations: OOP in Delphi – 1: Introduction to the Borland Delphi programming system. Objects (components) and their properties and OOP methods in Delphi – 2: The first program in Delphi, saving and compiling OOP in Delphi – 3: Programmatically changing the properties of OOP objects in Delphi – 4: Conditions in Delphi. Creating a simple OOP test in Delphi - 5: Elements of input and output of information. Exception handling OOP in Delphi – 6: Program screensaver and timer element OOP in Delphi – 7: Programming your toy OOP in Delphi – 8: Program menu, status panel, dialogs OOP in Delphi – 9: Creating your own text editor OOP in Delphi – 10: Databases in Delphi OOP in Delphi – 11: Calculator in Delphi. Handling exceptional situations OOP in Delphi – 12: Creating an OOP testing system in Delphi – 13: Graphics in Delphi.

Delphi uses the Pascal Object programming language, so it is better to first learn regular Pascal and work in TurboPascal, and then move on to Delphi - it will be very easy to switch, because the syntax of the language remains unchanged. It is advisable to study OOP in Delphi in senior specialized classes - the number of hours allocated to computer science there is quite enough to master the basics of OOP in Delphi

The series of presentations “OOP in Delphi” is dedicated to object-oriented programming with
using one of the most common rapid application development systems - Delphi
Using this training course, you can independently master the basics of object-based
oriented programming in Delphi. To expand your knowledge, attached to the course
a number of tutorials and reference books on Delphi
The series contains 13 presentations:
OOP in Delphi – 1: Introduction to the Borland Delphi programming system. Objects
(components) and their properties and methods
OOP in Delphi – 2: First Delphi program, saving and compiling
OOP in Delphi - 3: Programmatically changing object properties
OOP in Delphi - 4: Conditions in Delphi. Creating a Simple Test
OOP in Delphi – 5: Elements of information input and output. Exception Handling
OOP in Delphi – 6: Program splash screen and timer element
OOP in Delphi – 7: Programming your toy
OOP in Delphi – 8: Program menu, dialogs
OOP in Delphi – 9: Creating your own text editor
OOP in Delphi – 10: Databases in Delphi
OOP in Delphi – 11: Calculator in Delphi. Exception Handling
OOP in Delphi – 12: Creating a testing system
OOP in Delphi – 13: Graphics in Delphi
Delphi uses the Pascal Object programming language, so it is better to first learn regular Pascal and work in Turbo Pascal, and then
and switching to Delphi - it will be very easy to switch, because the syntax of the language remains unchanged.
It is advisable to study OOP in Delphi in senior specialized classes - the number of hours allocated to computer science there is quite
enough to master the basics of OOP in Delphi

Object –
oriented
programming in
DELPHI - 1
@ Krasnopolyansk school No. 1 Domnin Konstantin Mikhailovich 2006

DELPHI - 1
In this lesson:
Getting to know the system
Borland Delphi programming.
Objects (components) and their properties
Questions:
1. Introduction
2. Working window of the program
3. Delphi components
4. Objects and their properties

1. Introduction

Introduction
Delphi is a modern and powerful object-oriented system
rapid application development, allowing you to create the most
simple (educational, game applications) and complex database programs
data and enterprise management
Programming in Delphi is a fun process that you can
compare with assembling mosaics, children's blocks, construction sets, where the role
these cubes will be played by objects (buttons, inscriptions, Edit - s and others
Components)
Like in a constructor, we place these elements on our form,
Moreover, each element (object) has its own properties, which
we can manage
In addition, objects have their own methods - they are able to respond to
certain events (pressing a button, key...), in this case there will be
execute what we wrote in the code for processing this event
In this lesson we will get acquainted with the Delphi - 7 working window and, some of its common
used components (objects) and their properties

2. Working window
Delphi
Object – oriented programming on DELPHI - 1

Delphi working window
System
drop-down menus and
component panels
This is the window in which we
we will write code
programs
Object Inspector
(here we will be
change properties and
behavior of objects)
This is our uniform
which we will be
place objects

Delphi working window

Drop down menu system
containing functions for working with
files, project, settings
programs, etc.
(as in MS OFFICE)

Delphi working window
Let's start with the menu and component panel:
Standard toolbar
allowing the production of frequently used
actions with files, projects, forms

Delphi working window
Let's start with the menu and component panel:
Component panel of our
application containing
grouped tabs
objects
Standard and
most often
used
elements
Additional tab
elements that are now
open, below we see
elements that
this tab contains
Dialogues tab,
which we will too
use
As we work, we will use components from other panels as well.

3. Components
Delphi
Object-oriented programming in DELPHI - 1

Delphi components


1. STANDARDS tab
Frame - frame. On a par with
form serves as a container
to accommodate others
components. Unlike
forms can be placed in
component palette, creating
component parts
MainMenu - main menu
programs. Component
capable of creating and
serve complex
hierarchical menus like
for example, in MS Word and others
office programs, which has become
design standard
programs

Delphi components
Let's take a closer look at the components on the panel tabs
(naturally, to begin with, only the basic and frequently used ones)
1. STANDARDS tab
PopupMenu -
auxiliary or local
menu. Usually this is the menu
appears in a separate window
after right click
mice.
Label
- label. This component
used to place in
caption window.

Delphi components
Let's take a closer look at the components on the panel tabs
(naturally, to begin with, only the basic and frequently used ones)
1. STANDARDS tab
Edit
- input line.
Intended for input,
display or
editing one
text string.
Memo - multiline
text editor.
Used to enter and/or
display multiline
text.

Delphi components
Let's take a closer look at the components on the panel tabs
(naturally, to begin with, only the basic and frequently used ones)
1. STANDARDS tab
Button - command button.
OnClick event handler
this component is usually
used for implementation
some command.
CheckBox - independent
switch. Mouse click
on this component in
running program
changes its logical
property Checked.

Delphi components
Let's take a closer look at the components on the panel tabs
(naturally, to begin with, only the basic and frequently used ones)
1. STANDARDS tab
RadioButton
- dependent
switch. Usually
unites at least
with another one like that
component into the group. Click
by switch leads to
automatic
earlier release
selected switch in
same group
ListBox - selection list.
Contains a list of suggested
options (options) and gives
opportunity
check the current
choice. .

Delphi components
Let's take a closer look at the components on the panel tabs
(naturally, to begin with, only the basic and frequently used ones)
1. STANDARDS tab
ComboBox
combo list
choice. Represents
combination of picklist and
text editor
ScrollBar - strip
management. Is
be vertical or
horizontal stripe,
reminiscent of stripes
scrolling along the sides of the Windows window.

Delphi components
Let's take a closer look at the components on the panel tabs
(naturally, to begin with, only the basic and frequently used ones)
1. STANDARDS tab
GroupBox - group
elements. This component
used for grouping
several related
the meaning of the components.
RadioGroup - group
dependent switches.
Contains special
properties for maintenance
several related
dependent switches.

Delphi components
Let's take a closer look at the components on the panel tabs
(naturally, to begin with, only the basic and frequently used ones)
1. STANDARDS tab
Panel - panel. This
component, like GroupBox,
serves to unite
several components.
Contains internal and
outer edge that
allows you to create effects
“depression” and “convexity”.
Actiontist - list of actions.
Serves for centralized
program reactions to actions
user selection related
one of a group of similar
control elements such as
menu options, pictographic
buttons, etc.

Delphi components
1. ADDITIONAL tab

DrawGrid -
BitBtn-
command button with
inscription and
pictogram.
StringGrid - a table of strings. This
the component has powerful
opportunities for presentation
text information in a tabular
form.
free
table. Unlike
StringGrid cells
this component
may contain
arbitrary
information, including
including drawings.

Delphi components
1. ADDITIONAL tab
(Let's consider only some of the components we need)
ColorBox
Image - drawing.
This component
created for
display
drawings
-
special
ComboBox option
to select one
from system
colors
Chart - diagram. This
component makes it easy to create
special panels for
graphical representation
data.

Delphi components
Additionally, we will need some components from the tabs
Win32, Dialogs, System, Data Access
In view of the many components, we will limit their consideration here, with
further work with Delphi you will definitely need reference books and
electronic textbooks on Delphi, which are attached to this course

4. Objects and theirs
properties
Object-oriented programming in DELPHI - 1

Objects and their properties
Let's start with the main object of any application - the form.
Let's fire up Delphi and look at the properties
forms in the object inspector
The Object Inspector contains two tabs:
Parameters (here we change the properties
object)
Events (here we define when
upon the occurrence of which event will it be fulfilled?
our code)
Properties and events for objects, in
in particular for the form, a lot. IN
as part of our course we will look at
only simple and widely used

Objects and their properties
1. Align property(shape alignment on screen)
Align -
property,
defining position
forms on the screen. For example,
if we select this property
equal to the value of alClient, then
the form will take up the entire screen
Try setting the Align property
different values ​​and see how
the appearance and position of the form will change to
screen. To do this, click the button
"Run" on the toolbar
(or F9 key)
When considering the following
properties also try changing
values, run project (F9),
to see how it reflects
changing a property on a form (or
another object)

Objects and their properties
2. AlfaBlend property (object transparency)
AlfaBlend – turns on and off the transparency of the form
AlfaBlendValue – allows you to set the degree of transparency
Set the AlfaBlend property to True and the
AlfaBlendValue – value 100, run (F9), and the form
becomes transparent
3. AutoScroll property (automatic
scroll bar appears)
When enabled (true), the form will automatically display
scroll bar if the size of objects exceeds
mold dimensions
4. Property AutoSize(automatic
setting the form size)
When enabled (true), the form dimensions are automatically adjusted to fit
sizes of objects on it

Objects and their properties
5. BorderIcons property (type of icons in the form header)
Setting these properties allows us to enable or disable
buttons for working with the window on our form
For example, if the biMinimize property is set to False, then
our window will not have a button to minimize the window (it will
unavailable)
6. The BorderStyle property determines the appearance
the borders of our window
For example, the value bsSingle makes the border thin, and the value
bsNone makes the form have no border at all (this is often
used when creating screensavers for programs)

Objects and their properties
7. Caption property (defines the title of the program window)
If you enter the word Calculator here, then
it automatically fits into
window title
8. The Color property defines the color
our form
On the right side there is
a set of flowers that
can be opened and selected
necessary.
If you are not satisfied with this
set, make it double
right mouse click
parts of the property and select
the color you want

Objects and their properties
9. Enabled property (object availability)
If the property is false, the object will be unavailable (inactive)
10. Font property (font settings)
Here you can change the size, color and writing of the test on
objects
11. FormStyle property (form style)
Defines the style of the form. For example, if this property
give the value fsStayOnTop, then the form dimensions cannot be
change, clinging to its boundaries
12. Icon property (program window icon)
Defines an icon in the program window,
which you can choose from
available or draw yourself

Objects and their properties
13. VertScrollBar property (defines
presence and type of vertical stripe
scrolling
14. Visible property (determines the visibility
object)
If the property value is true, then the object is visible, and if
false – the object is not visible
14. VindowState property (defines the status of the program window when
its launch)
Depending on the value of this property, the program window can be launched in a maximized position.
Full screen (maximized), minimized (minimized) or normal view
So, we looked at some properties of objects (in particular shapes) and
tried them in action. Similarly for each object (buttons, Edit,
Memo, Timer...) have their own properties that have a lot in common and
some differences

Objects and their properties
Now let’s look at what events form objects can respond to.
To do this, let's place a BUTTON on our form. How
do this?
We look for the STANDARDS tab in the Delphi panel, on it
element BUTTON (Button), click on it, and then
Click on the form and a button appears
Change the Caption property of the button to EXIT
Now let's go to the EVENTS tab
facilities inspector
Main event for many objects, and
especially for a button - this is a mouse click on
him OnClick
Double click on the white area of ​​this
properties and you will see a window with the program code:
close
Insert a close statement between the words begin and end, then
run the program (F9) and press the button - the button works,
those. when the button click event occurs, the
window closing code (close)

Delphi components
In addition to the most applicable click event
button exists and many others, for example event
hovering the mouse over the OnMouseMove object
With these events and their processing we
let's get acquainted with our
course

RESULTS OF THE LESSON:
In this lesson we got acquainted with the system
Borland Delphi programming, Objects (components) and
their properties
IN NEXT LESSON:
OOP in Delphi - 2:
First Delphi program, saving and compiling
You will learn how to save and compile a project,
create your first program, learn to read the source
module code

Domnin Konstantin Mikhailovich
E-mail:
2006

Municipal educational institution

Secondary school No. 1

With. Obsharovki

DELPHI. Introduction to the programming system

Development by computer science teacher Vyacheslav Aleksandrovich Maksimov.


Delphi. Main characteristics of the product.

Delphi is a combination of several important technologies:

  • High-performance compiler to machine code
  • Object-oriented component model
  • Visual (and, therefore, high-speed) construction of applications from software prototypes
  • Scalable tools for building databases

Object-oriented model of software components

The main focus of this model is Delphi is done to maximize code reuse. This allows developers to build applications very quickly from pre-prepared objects, and also gives them the ability to create their own objects for the environment Delphi. There are no restrictions on the types of objects that developers can create. Indeed, everything in Delphi is written in the same language, so developers have access to the same objects and tools that were used to create the development environment. As a result, there is no difference between the objects supplied by Borland or third parties and the objects you can create.


Rapid development of a working application from prototypes

The Rendzu game program was assembled from ready-made pieces in a working day, with most of the time devoted to preening and embellishment.


Application Development

Screen Saver in the form of a jumping clock was also made at Delphi in a very short time. Now this watch adorns almost every IBM-compatible machine


Who is Delphi for?

First of all Delphi designed for professional developers of corporate information systems

Delphi is intended not only for professional programmers.

Apply Delphi teachers, doctors, university professors, businessmen, all those who use a computer for a purely applied purpose.


Library of visual components

This object library includes standard user interface objects, data management objects, graphics objects, media objects, dialog and file management objects, DDE and OLE management.


Delphi: a customizable development environment

palette component .

Components are grouped on palette pages by their functions. For example, the components that represent Windows "common dialogs" are all located on a palette page called "Dialogs". .

Delphi allows developers to customize the environment for maximum convenience. You can easily change the component palette, toolbar, and also customize syntax highlighting.

Note that in Delphi you can define your group of components and place it on the palette page, and if the need arises, rearrange components or remove unused ones.

From this palette

component

you can choose

Components,

from which you can

build applications.

Components include

into ourselves as visual,

and logical components.

After launch Delphi

in the top window

horizontally

icons are located

component palettes.

If the cursor

delayed for

one of the icons,

under her in

yellow rectangle

a hint appears

palette page called “Dialogs”


Smart Editor

Editing programs can be done using recording and executing macros, working with text blocks, customizable key combinations and color highlighting of lines.


Object Inspector

This tool is a separate window where you can set the values ​​of properties and events of objects (Properties & Events) during program design.


Project Manager.

Allows the developer to view all modules in the corresponding project and provides a convenient mechanism for project management. The Project Manager shows file names, time/date of selected forms, etc. You can immediately get to the text or form by simply clicking on the corresponding name.


Object navigator

Shows

library

available objects

Implements

navigation

In your

application.

You can see

hierarchy

objects,

precompiled

modules in the library,

list of global

names of your code.


Database application development

Delphi allows

use

library of visual

component for fast

creating reliable applications,

which are easily expandable

to applications with architecture

client-server.

In other words, you can create an application

working with local server InterBase,

and then use the created application,

connecting to a remote SQL server via SQL-Links.


Delphi is primarily a development environment based

on using the component.

So you can add completely new components

to the component palette.

You can create components internally Delphi ,

or introduce components created as controls

VBX or OLE 2.0, or you can use components

written in C or C++ as dll.


Hardware and software requirements

Windows 3.1 and higher

27 Mb of disk space for minimum configuration

50 Mb of disk space for normal configuration

processor 80386, or better 80486


  • . Many developers around the world are already firmly focused on using Delphi as a tool that allows you to create highly efficient client-server applications. Moreover, the list of ready-made, professionally executed applications is so large that it is not possible to list it completely in this presentation. Range developed using Delphi software products is also amazing - from gaming programs to the most powerful banking systems.

  • DELPHI. Subtleties of programming. Vasily Kucherenko.- M: “Educational book plus”, 2000, -192 p.
  • Let's study DELPHI. A. Zhukov. PETER. 2002.
Internet