What is the difference between the read and readln input operators? Topic: Input - output. Operators Read (Readln), Write (Writeln). The simplest linear programs. The read and readln operators. Information Entry Procedures

The Pascal programming language uses instructions such as read and readLn. What are they?

What is a read statement?

This instruction is intended to provide input of various variable values ​​from the PC keyboard when using the Pascal language. The scheme for using the instruction in question looks simple: like read (“variable value”).

In practice, the read instruction is used to ensure that certain data is read from a file and the subsequent assignment of values ​​extracted from the corresponding data to the variables that are specified when calling the procedure.

If the user makes a mistake when entering data; it does not correspond to any type of variable reflected in the instructions, the program stops executing commands. At the same time, a message appears on the PC screen stating that an error has occurred in the application.

If the programmer uses several read instructions, then the data will somehow be entered on one line. A transition to the next one is possible only if the current line ends. However, you can read information located in another line using the readLn instruction. Let's take a closer look at its features.

What is the readLn instruction?

The essence of the readLn instruction is to set a condition in the program under which:

  • any number entered into the line is assigned to the last variable according to the instruction;
  • the remaining area of ​​the line is not processed by the program, while the next instruction will require new input.

So, you can enter the instruction:

readLn(C,D); read(E);

And if after this you enter the series 1 2 3 from the keyboard, then the variable C will acquire the value 1, D - 2. But the program will not assign a specific value to the variable E until the user enters a new number.

As with the read instruction, if the user enters an incorrect data type using the readLn command, the program exits and displays a message indicating that an error occurred.

Comparison

The main difference between readLn and read is that the first procedure involves the program moving to the line of the file following the one in which the instructions are written. The second procedure allows the program to read the data located in the next line only with the user's permission - if he presses Enter.

In practice, the readLn instruction is most often used to provide a delay between the result of the application execution and the transition to the next instruction. The corresponding delay lasts until the user presses Enter.

Having determined what the difference is between readLn and read in the Pascal language, we record the conclusions in the table.

Read (procedure)

For typed files, reads the file component into a variable.
- For text files, reads one or more values
into one or more variables

Announcement

Typed files

Procedure Read(F , V1 [, V2,...,Vn ]);

Text files

Procedure Read([ Var F: Text; ] V1 [, V2,...,Vn ]);

Mode

Windows, Real, Protected

Notes

For string variables:

Read reads all characters up to (but not including) the next end-of-line marker or until Eof(F) will become True. Read doesn't move to the next line after reading. If the resulting string is longer than the maximum length of the string variable, it is truncated. After the first Read, each subsequent Read call will see an end-of-line marker and return a zero-length string.

Use multiple ReadLn calls to read multiple string values.

When the option is enabled Extended Syntax, the Read procedure can read null-terminated strings into null-based character arrays.

For variables of type Integer or Real:

Read will skip any spaces, tabs, or end-of-line markers preceding a numeric line. If the numeric string does not follow the expected format, an I/O error occurs, otherwise the variable is assigned the resulting value. The next Read will begin with the space, tab, or end-of-line marker that terminated the number line.

see also

Example

uses Crt, Dos;

var
F:Text;
Ch:Char;

begin
(Getting the file name from command line }
Assign(F, ParamStr(1));
Reset(F);
while not EOF (F) do
begin
Read(F, Ch);
Write(Ch); (Display the contents of the file on the screen)
end ;
end.

You are in the Pascal programming materials section. Before we start programming, we need to clarify some concepts that we will need in the beginning. After all, you can’t just program like that. We cannot write the program in words - the computer does not understand anything other than zeros and ones. For this purpose, special symbolism was created in Pascal - the Pascal language, a set of reserved words that cannot be used anywhere else in your programs except for their intended purpose. Let's list the basic concepts that we will need at the beginning:

✎ 1) program – in English “program”, written at the very beginning of the code, followed by the name of the program in Latin and a semicolon. For example: program Summa; − a program called Summa. But this part of the code, called the program header, does not need to be written - it is present only for clarity and shows what problem it solves this program. Here we used the word “code” - this is the name of the text entry of the program.

✎ 2) integer – in English means “integer” (or simply “integer”) and in Pascal is used to denote 32-bit (8 bytes) signed integers from the range [-2147483648, 2147483647] . We will look into what these large numbers mean later.

✎ 3) real – from English “real”, “real”, “real”, “real”. In the Pascal language, this term denotes real numbers in the range [-1.8∙10 308, 1.8∙10 308]. These are very large numbers, but 15 - 16 significant digits are displayed. By the way, the integer and real data types in the PascalABC.Net programming environment are always automatically highlighted in blue.

✎ 4) const – analogue of English. "constant", meaning "constant", "constant". In Pascal, this is a quantity that cannot change. It is written like this:


This entry must be taken as it is written: the number N is 12, S is 5, “pi” is 3.14 (as in mathematics, only a dot is used instead of a comma in Pascal). In the last line we used a double slash (two forward slashes), followed by text - this is how comments are written in Pascal, and the program does not perceive them. Everything that begins with a double slash and until the end of the line is a comment, which is written to explain the program and is always highlighted in a different color (in PascalABC.Net it is green; Turbo Pascal does not use this type of comment). There is another type of commentary - this is (text enclosed in braces, just like here, also highlighted in green). This type of comment can be valid for several lines in a row - from the beginning of the bracket to its closing, and the compiler does not perceive everything that is in the middle of such a construction as code and simply skips it.

In reality the recording format const a little more complicated. According to the rules, we had to write:

1 2 3 4 const N: type integer;

Description:

")" onmouseout="toolTip()">integer
= 12 ; //number N – integer type S: type integer;

Description:
Represents a 32-bit signed integer.

Value range: -2 147 483 648 .. 2 147 483 647")" onmouseout="toolTip()">integer
= 5 ; //number S – integer type pi: type real;

Description:
Represents a double precision floating point number.

Size: 8 bytes
Number of significant figures: 15 - 16
Value range: -1.8∙10 308 .. 1.8∙10 308
")" onmouseout="toolTip()">real
= 3.14 ; //number "pi" - real

After declaring each value, its type is indicated, and then a value is assigned. But the previous entry is also correct, since the Pascal compiler is configured so that it automatically determines the type of a constant. But this cannot be said about the next type of numbers - variables.

✎ 5) var – comes from English. “variable” (“variable” or “changeable”), which in Pascal means a value that can change its value during the program. It is written like this:


As can be seen from the entry, there is no “=” sign here - variables of the same type are recalculated (separated by commas) and only the type is indicated after the colon. The variables N, m (integer) and Q, r, t (real) in the program can change values ​​within the limits of integer and real, respectively. One more note: the description of variables always comes after the description of constants (constants) - the const construction comes first, and then var.

✎ 6) begin – translated from English means “to begin” and Pascal means the beginning of the main program in which commands (operators) are written. After the word begin There is no semicolon.

✎ 7) end – in English. “end”, and in Pascal it means the same thing (end of the program). After the last word end there is always a period. We have emphasized the word “last” because the use of the construction begin–end perhaps in one more case: these are the so-called operator brackets, which are used to combine several operations under one operator. But more on that later. So the main program will look like this:

1 2 3 4 5 6 begin < оператор 1 > ; < оператор 2 > ; . . . . . . . < оператор N > ; end.

Here, the operators in the body of the program are different commands to the compiler.

✎ 8) write – in English means “to write”. This operator displays the text placed in it, which is why it is called the output operator. The text placed inside it is highlighted in blue and written like this:

Write( "this text is displayed on the screen");

A message inside parentheses and quotes will be shown in the console window (you can't just put it in parentheses without quotes). After executing this statement we will see on the screen:

this text is displayed on the screen

In this form, the write operator is used in the case when you need to show a hint, explanation, comment, etc. And if you also need to display a numerical value, say, S = 50 sq. m, then the format is used:

Write(, S);

As a result, we get the result on the screen:

The area is equal to: S = 50

And if you need to display units of measurement, you need to insert the text in quotes again after S:

Write( "The area is equal to: S = ", S, " sq.m" );

After executing the last output statement, we get the following output on the screen:

The size of the area is: S = 50 sq.m

✎ 9) writeln – the same as write, but after execution the cursor will be moved to the next line.

✎ 10) read – translated from English means “to read”, so read is called the read or data input operator. It is written as read(N), which means that the value N must be entered, where N is any number, or text, or other type of variable. For example, if we need to enter the age of a person who is 32 years old, we can write it like this:


In the first line of this code, the program displays the question “ What is your age?" and moves the cursor to the next line (ending ln); in the second line we print “Year =” (space at the beginning); Next we see the readln(Year) operator, which means it is necessary to enter the age Year (number 32); finally, we display the messages “My age”, “32” and “years. " one by one. You need to watch the spaces carefully. As a result of executing this code, we will receive the message:

What is your age?
Year = 32
My age is 32 years old

✎ 11) readln – the same as read, only with a new line. Indeed, in the above example, after introducing the number Year, we only write in the next line: “ My age is 32 years old».

That's all for now. On the next page we will write the first program, and in Pascal programming this will be our

I think many people will be interested in this)))

read and readln instructions

The read instruction is intended for entering variable values ​​(initial data) from the keyboard. In general, the instructions look like this:

read (Variable1, Variable2, ... VariableN)

where variables is the name of the variable whose value must be entered from the keyboard during program execution.

Here are examples of writing a read instruction:

read(a); read(Cena,Kol);

When the read statement is executed, the following happens:

1. The program pauses its work and waits until the required data is typed on the keyboard and a key is pressed .

2 http://tissot.ua/ buy wristwatch watches buy Kyiv. . After pressing the key the entered value is assigned to the variable whose name is specified in the statement.

For example, as a result of executing the instruction

read(Temperat);

and entering line 21 from the keyboard, the value of the Temperat variable will be the number 21.

A single read statement can retrieve the values ​​of multiple variables. In this case, the entered numbers must be typed on one line and separated by spaces. For example, if the type of variables a, b and c is real, then as a result of executing the instruction read(a,b,c); and enter the line from the keyboard:

4.5 23 0.17

the variables will have the following values:

a = 4.5; b = 23.0; c = 0.17.

If there are more numbers typed in a line than the variables specified in the read instruction, then the remaining part of the line will be processed by the following read instruction http://crystal.lviv.ua crystal crystal. . https://mainvisa.com.ua photo invitation to Ukraine for foreign citizens. . For example, as a result of executing instructions

read(A,B); read(C);

and keyboard input string

10 25 18

the variables will receive the following values: A = 10, B = 25. Read instruction (C); will assign the value 18 to variable c.

The readln instruction differs from the read instruction in that after selecting the next number from the string entered from the keyboard and assigning it to the last variable from the list of the readin instruction, the remainder of the line is lost, and the next read or readin instruction will require new input.

For example, as a result of executing the instruction

readin(A,B); read(C);

and entering the line from the keyboard

10 25 18

the variables will receive the following values: A = 10, B = 25. After which the program will wait for a new number to be entered in order to assign it to variable c.

Each read or readin instruction should be preceded by a write instruction to tell the user what data the program expects from him. For example, a fragment of a program for calculating the cost of a purchase may look like:

writeln("Enter initial data.");

Write("Item price:");

Readln(Cena);

write("Quantity in batch:");

Readln(Kol);

write("Discount:");

readln(Skidka);

If the type of data entered from the keyboard does not match or cannot be cast to the type of the variables whose names are specified in the read (readin) statement, then the program crashes (instructions following read are not executed) and a message is printed on the screen about the error.

4. Write and writeln operators. Output procedures

You noticed that the program used the write and writeln operators. The English word write is translated - to write, and the word writeln comes as an abbreviation of two English words write - to write and line - line.

In addition to the write and writeln operators, we are talking about information output procedures.

What is it procedure ?

The concept of procedure is one of Pascal's main concepts. A subroutine in the BASIC language is similar to it.

Procedure is a certain sequence of Pascal language operators that has a name and can be accessed from anywhere in the main program by specifying its name.

Above we talked about information output operators, although in Pascal, unlike BASIC, there are no information output operators, and through the service words write and writeln access is made to standard or built-in information output procedure. The standard procedure does not need a preliminary description; it is available to any program that contains a call to it. That is why calling write or writeln resembles the PRINT operator - outputting information in the BASIC language.

Difference between output operator and appeal to withdrawal procedure is that the name of the output procedure, like any other Pascal procedure, is not a reserved word, and, therefore, the user can write his own procedure named write or writeln. But this is very rarely used in practice.

Thus, the write and writeln operators are operators for accessing built-in information output procedures.

Both of these procedures display information on the screen, if this information is contained in the form of variable values, then it is enough to write the names of these variables in parentheses in the write or writeln statements, for example: write(a), writeln(f). If there are several such variables, then they are written separated by commas, for example: write(a, b, c, d), writeln(e,f, g, h).

If the information is words, sentences, parts of words or symbols, then it is contained between the signs "; " "; - apostrophe, For example:

write("Enter path length"),

writeln("The speed value is"

Simultaneous output of both symbolic information and variable values ​​is possible, then in the write or writeln statement they are separated by commas, for example:

write("The temperature value is ", t),

writeln("The speed is ", v, " at the time of movement ", t).

Notice that at the end of words there is a space left before the apostrophe.

Why is this done?? Of course, the following numeric information should be separated from the words by a space.

What is difference in the work of the write and writeln procedures?

The write procedure requires the following input or output procedures to either input or output information on the same line (on the same line).

If a program specifies a write statement and is followed by another write or writeln statement, then the information they output will be appended to the information line of the first write statement.

For example: write("Today and tomorrow will be ");

write("weekends");

The screen displays:

Today and tomorrow will be days off

Space between the word ";will"; and ";weekend"; is provided by a space at the end of the first line. If it is not there, then the output will occur seamlessly :

write("Today and tomorrow will be");

write("weekends");

Today and tomorrow will be holidays

Some more examples: t:=20;

write("Movement time is ");

write(" seconds");

Movement time is 20 seconds

write("The sum of the numbers is ");

write(", and the product ");

The sum of the numbers is 30, and the product is 216

Procedure writelnprovides for the following procedures for entering or outputting information to enter or output it from the beginning of each new line .

In a programme:

writeln("Tonight, tonight, tonight");

writeln("When pilots, frankly, have nothing to do");

The screen displays:

Tonight, tonight, tonight,

When pilots, frankly speaking, have nothing to do

In a programme:

writeln("The sum and difference of the numbers are equal:");

On the screen:

The sum and difference of the numbers are equal:

5. Read and readln operators. Information Entry Procedures

Just like for information output operators, the read and reeadln operators are operators for accessing built-in information entry procedures.

The operators read (read) and readln, which comes from two English words read (read) and line (line), are used in programs to enter information into computer memory and "; reading"; values ​​into a variable.

Let's consider the work of these operators and information entry procedures.

Our program has a procedure readln(a). When executing a program, encountering a readln statement, the computer will pause while waiting for input. After we enter the value of variable a - 16 from the keyboard, the computer will assign this value to variable a, i.e. will send it to a memory location named a and will continue executing the program. We call this process "; reading"; values ​​into a variable.

So, the read and readln procedures ";read"; values ​​of variables and assign them to the variables that are written in them.

There can be several such variables, then they are written in these operators separated by commas, for example:

read(a, b, c, n, g, j, i), readln(e, f, k, p, d), etc.

What is the difference between the work of the read and readln procedures?

The read procedure will require input or output of information on one line after itself, and the readln procedure allows you to enter and output information after itself from the beginning of a new line.

For example:

In the program: write("Enter the values ​​of a and b "); read(a, b);

write("Enter information on one line");

When this part of the program is executed, everything written in the first write statement will be displayed on the screen, then the cursor will be located on the same line, and the computer will wait for the values ​​a and b to be entered. Let's enter their values ​​- 2 and 3, separating them with a space or, in other words, separated by a space. After this, the same line will display the information written in the next write statement.

On the screen:

Enter the values ​​of a and b 2 3 Enter information on one line

In a programme:

writeln("Enter the values ​​of a, b and c); readln(a, b, c);

writeln("Input and output information from the beginning of the line");

On the screen:

Enter the values ​​of a, b and c

Entering and outputting information from the beginning of the line

Chapter 2. Entering and Executing Programs

1. In the integrated environment Turbo Pascal 7.0.

After launching Turbo Pascal, the following shell will appear on the screen (see Fig. 3):

Rice. 3

The top line of the window that opens contains "; menu"; possible operating modes of Turbo Pascal, the bottom - a brief information about the purpose of the main function keys. The rest of the screen belongs to the window text editor, outlined by a double frame and intended for entering and editing program text.

When we enter a program, we work with a text editor built into the Turbo Pascal environment. Therefore, below we will get acquainted with the work of the editor and its main commands.

A sign that the environment is in an editing state is the presence of a cursor in the editor window - a small blinking dash.

To create program text, you need to enter this text using the keyboard, similar to what is done when typing text on a typewriter. After filling out the next line, press the B>Enter> "; Enter"; to move the cursor to the next line (the cursor always shows the place on the screen where the next entered program character will be placed).

The editor window imitates a long and fairly wide sheet of paper, part of which is visible in the screen window. If the cursor reaches the bottom edge, the editor window scrolls: its contents move up one line and a new line ";" appears at the bottom. sheet";. The longest line length in Turbo Pascal is 126 characters.

The window can be shifted relative to the sheet using the following keys:

PgUp- page up ( PaGeUP- page up);

PgDn- page down ( PaGe DowN- page down);

Home- to the beginning of the current line ( HOME- home);

End- to the end of the current line ( END- end);

Ctrl-PgUp- to the beginning of the text;

Ctrl-PgDn- to the end of the text.

Cursor keys “ cursor” can be moved to fit the text on the screen (note, only text!). By "; pure "; if the screen is not covered with writing, the cursor does not move!

If you make a mistake when entering the next character, you can erase it using the key indicated by the left arrow (key Backspace- B>Back>, it is located on the right and at the top of the zone of the main alphanumeric keys above the B>Enter> key - “ Enter"). B>Del key ete> (Delete - erase, delete) erases the character the cursor is currently pointing at, and the Ctrl-Y command erases the entire line on which the cursor is located. It should be remembered that the Turbo Pascal editor inserts a separator character that is invisible on the screen at the end of each line. This character is inserted with the B>Enter> key, and erased with the B>Backspace> or B>Del key ete> . By inserting/erasing a separator you can "; cut”/";glue"; lines.

To "; cut"; line, move the cursor to the desired location and press the B>Enter> key to "; glue"; adjacent lines, you need to place the cursor at the end of the first line and press the B>Del key ete> or place the cursor at the beginning of the next line and press the B>Backspace> key.

Insert mode

The normal operating mode of the editor is insertion mode, in which each newly entered character is like a "; spreads"; text on the screen, shifting the rest of the line to the right. Please note that "; cutting"; and subsequent insertion of missing characters is possible only in this mode.

Examples "; cutting";, ";gluing"; lines and inserting characters into text.

Suppose for some reason the following entry is received on the screen:

Program Serg; var

a, b, c: integer;

If we talk about the aesthetic side of writing a program, then it is desirable that the description section, which begins with the word var, started with a red line. To make changes to the text, place the cursor on the letter v and press the B>Enter> key, while part of the text after the cursor and below it will move to the next line, we get:

Program Serg;

a, b, c: integer;

For greater beauty and clarity, without moving the cursor, but leaving it on the letter v, press the B>Space> key several times. The entire line will move to the right and the entry will look like this:

Program Serg;

a, b, c: integer;

Let's assume another situation, when part of the text "; exploded"; and we need it "; glue";, for example, it turned out like this:

write("Enter the number of years that

the swarm would be Seryozha ";);

Place the cursor at the beginning of the second line before the letter ";р"; and press the B>Back> key, we get:

write("Enter the number of years Seryozha would be");

You can do it differently, place the cursor at the end of the first line after the letter ";o"; and pressing the B>Delete> key several times ";pull up"; bottom line up.

Using the B>Back> and B>Del keys ete> Can "; unite"; ";torn” line. For example, in this situation:

write("Enter the number of years Seryozha would be");

Place the cursor in front of the letter ";d"; and press the B>Backspace> key several times until the word “;Enter”; will accept the desired construction, or by placing the cursor after the letter “e”; Press the B>Delete> key several times.

Inserting missing characters is made even easier.

For example, you missed a few letters:

wrte("You are the number of years that Serge would be");

The letter ";i"; is missing in the first word, and in the word ";Enter" two letters ";di"; are missing in the word ";Seryozha"; the letters ";er";.

Place the cursor on the letter ";t"; in the first word and type “;i”; from the keyboard, it will immediately be inserted into the right place. Next, place the cursor on the letter ";t"; in the word ";Vvete"; and type “di” from the keyboard, the word “; will spread apart"; and the letters ";di"; will fall into place. Place the cursor on ";e"; in the word ";Sezha"; and type ";er";,

Blend Mode

The editor can also work in the mode of overlaying new characters on existing old text: in this mode, the new character replaces the character the cursor is pointing at, and the rest of the line to the right of the cursor is not shifted to the right. To switch to the blending mode, press the B>Ins key ert> (Insert- insert), if you press this key again, the insert mode will be restored again. An indication of which mode the editor is working in is the shape of the cursor: in insert mode, the cursor looks like a blinking underscore, and in overlay mode it is a large blinking rectangle that obscures the entire character.

Auto indent mode

Another feature of the editor is that it usually works in auto-indent mode. In this mode, each new line begins at the same screen position as the previous one.

The auto-indent mode supports a good design style for program texts: indentations from the left edge highlight various statements and make the program more clear.

You can cancel auto-indent mode with the command Ctrl-O I(with the key pressed Ctrl key is pressed first O, then key O the key is released and pressed I), repeat command Ctrl-O I will restore auto-indent mode.

The most commonly used commands are listed below text editor Turbo Pascal, except those given above.

Editing commands

Backspace- B>Back> - erase the character to the left of the cursor;

Del- erase the character the cursor is pointing at;

Ctrl-Y- erase the line on which the cursor is located;

Enter- B>Enter> - insert a new line, "; cut"; old;

Ctrl-Q L- restore the current line (valid if

the cursor did not leave the modified line).

Working with a block

Ctrl-K B- mark the beginning of the block;

Ctrl-K Y- erase the block;

Ctrl-K V- move the block;

Ctrl-K P- print a block;

Ctrl-K H- hide/display the block (uncheck);

Ctrl-K K- mark the end of the block;

Ctrl-K C- copy block;

Ctrl-K W- write the block to a disk file;

Program Execution

After the program has been typed, you can try to execute it.

To do this, press the B>Ctrl>+ keys (hold down the B>Ctrl> key and press the B>F9> key). The same operation can be performed by going to the main menu, pressing the B>F10> key, and then moving the pointer to select the option Run and press the B>Enter> key.

A second-level menu associated with this option will open on the screen. The new menu is like "; falls out"; from the top line, which is why such a menu is often called a pull-down menu. The screen will look like this (see Fig. 4):

Rice. 4

Now you need to find the option in the new menu RUN(start) and press the B>Enter> key.

If there was no error when entering text, then after a few seconds the image on the screen will change. Turbo Pascal puts the screen at the disposal of the user's running program. This screen is called program window.

In response to the request:

Enter the number of years that Seryozha would be, enter 16 and press B>Enter>.

After the run is completed (the operation of the program is often called its run), the editor window with the text of the program will again appear on the screen. If you did not have time to see the image of the program window, then press Alt-F5. In this case, the editor window will hide and you will be able to see the results of the program. To return the screen to the editor window playback mode, press any key.

You can make the screen more convenient to see the results of the program. To do this, you can open a second window at the bottom of the screen.

To do this, press the F10 key to go to selection mode from the main menu, move the pointer to the option Debug(debug) and press the B>Enter> key - a second-level menu associated with this option will open on the screen. The screen will look like this (see Fig. 5):


Rice. 5

Find the OUTPUT option in the new menu, move the pointer to it and press B>Enter>.

A second window will appear at the bottom of the screen, but it will no longer disappear.

Now let's ensure that two windows are shown on the screen at the same time: press the F10 key again, select WINDOW, press B>Enter>, move the pointer to the option TILE(tile) and press B>Enter>.

If everything is done correctly, the screen will look like (see Fig. 6):

Rice. 6

A double frame outlining the program window indicates that this particular window is currently active.

Let's make the editor window active: press the B>Alt> key and, without releasing it, press the key with the number 1 (the editor window is number 1, the program window is number 2, these numbers are written in the upper right corners of the frames). Now everything is ready for further work with the program.

First mistakes and their correction

1. There is no semicolon, for example, after the readln(a) statement. After starting the program, by pressing the B>Ctrl>+B>F9> keys, a message written in red will appear in the top line of the screen:

Error 85: ";;"; expected.

(Error 85: ";;"; is missing.)

The editor will set the cursor to the next character after the missing character, in our example to the variable b. After pressing any key, the error message disappears and the editor switches to insert mode. You need to move the cursor to the desired place, put a semicolon - “;” and continue working.

2. A variable is not written in the description of variables, but it is present in the program, for example a variable c. After starting the program, the following message will be displayed:

Error 3: Unknown identifier.

(Error 3: Unknown ID.)

The cursor will be placed on this variable, in our example on the variable c. The error must be corrected, i.e. write a variable c to the variable descriptions section and continue working.

3. There is no period after the operator end at the end of the program. The compiler message will be like this:

Error 10: Unexpected end of file.

(Error 10: Invalid end of file.),

the cursor will be placed on the letter "; e"; in a word "; end";. We need to put an end to it and run the program again.

Writing a file to disk

So, the program has been edited and executed (scrolled), now it needs to be written to disk. To do this, you can use the main menu, in which select the option "; File"; (see Fig. 7). The sequence of actions is as follows: 1) press the F10 key and go to the main menu; 2) move the pointer to the option "; File"; and press B>Enter>, a second menu of options will open "; File";:

Rice. 7

You can select the option "; Save";. It writes the contents of the active editor window to a disk file.

If you press B>Enter>, the environment will ask for a file name if one was not set and the window was associated with the name NONAME00.PAS. You can change the name, or leave it the same.

This option is called directly from the editor using the B>F2> key.

You can select the option SAVEAS. It writes the contents of the active editor window to a disk file under a different name.

The dialog box for this option looks like (see Fig. 8):

Rice. 8

In the input field you must write the name of the file into which the contents of the active editor window will be copied. You can select an existing file from the selection field or from the protocol with options. In this case, depending on your environment settings, the old contents of the file will be destroyed or saved as a backup copy with a .BAK extension.

Line by line recording of program text

In Pascal there are no rules for breaking program text into lines.

However, to write a program, you can give some

It is very important that the program text is arranged clearly, not only for the sake of beauty, but (and this is the main thing!) to avoid errors. (It’s much easier to find errors in visual text.)

1. Each statement should be written on a new line, with the exception of short and meaningfully related statements.

For example,

write ... readln ... - written on one line, short assignment operators can be written on one line:

a:= 23; b:= 105; c:= -11.2.

2. Operators of the same level located on different lines must be aligned vertically, i.e. equally spaced from the left edge.

For example, let's write down a sequence of operators to determine the sum of the digits of a three-digit number:

s:=a div 100;

d:=a div 10 mod 10;

e:=a mod 10;

Here all the operators are equal, they follow each other sequentially, so they all start from the same vertical position.

3. Operators included in another operator should be shifted to the right by several positions (preferably equally).

if...then

4. It is recommended to vertically align base word pairs: begin And end, with which we have already become acquainted, as well as words with which we will become acquainted later: repeat And until, record And end, case And end.

Here are some of the most popular operator placement options if:

A) if...then ...

else ...

b) if...then ...

else...

V) if...

then ...

else ...

G) if ...

then ...

else ...

d) if ... then ... else ...

6. Comments are written either next to the construction (identifier, operator, part of it) that they explain, or on a separate line.

Document

programming programming programming, general... Grobovaya silence. › Several times paired programming passed...

  • Alistair Cowburn pair programming advantages and disadvantages

    Document

    Research related programming and organizational effectiveness. Amazing... language programming, certain design methods and programming, general... Grobovaya silence. › Several times paired programming passed...

  • Introduction to Neuro-Linguistic Programming The Newest Psychology of Personal Mastery

    Document

    Will it be called?" The result was Neurolinguistic programming- a cumbersome phrase behind which hides... taciturn, vocal, sound, voice, speaks, silence, dissonance, consonant, harmonious, piercing, quiet...

  • NEUROLINGUISTIC PROGRAMMING (a manual for beginners)

    Document

    PSYCHOTHERAPY CENTER "LAD" V.I. ELMANOVICH NEUROLINGUISTIC PROGRAMMING(methodological manual for beginners) PART 1. ... MODALITIES (A). 1. If volume = 0, then “listens” silence", if the volume is maximum, then “lit...

  • 
    Top