Syntax error expected but found паскаль

Ошибка "Syntax Error, ":" expected but ";" found Free Pascal Решение и ответ на вопрос 429619

XpycT36

0 / 0 / 0

Регистрация: 09.01.2012

Сообщений: 6

1

17.01.2012, 01:50. Показов 35843. Ответов 7

Метки нет (Все метки)


Pascal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
Unit SourceModMenu;
 
interface
 
Uses Crt;
 
function Menu(X,Y: integer):integer; //Функция для меню
Procedure Menu80; // Процедура для функции Menu. При нажатии стрелкии вверх
Procedure Menu72; // Процедура для функции Menu. При нажатии стрелкии вниз
 
var Choose: integer;
 
implementation
 
var
CurrStr: integer;
strall1: string;
strall2: string;
strall3: string;
 
Function Menu(X,Y: integer;str1,str2,str3: string):integer;
var
key: char;
CucleEnd: boolean;
begin
Clrscr;
CurrStr:=1;
strall1:=str1;
strall2:=str2;
strall3:=str3;
GoToXY(X,Y);
TextColor(Black);
TextBackground(White);
write(str1);
TextColor(White);
TextBackground(Black);
write(str2);
repeat
key:=readkey;
if key=chr(0) then
key:=readkey;
if key=chr(80) then
Menu80;
if key=chr(72) then
Menu72;
if key=chr(13) then
CucleEnd:=true;
until CucleEnd=true;
Menu:=Choose;
end;
 
Function Menu80;
begin
case (CurrStr) of
2:
begin
TextColor(White);
TextBackgroud(Black);
write(strall2);
CurrStr:=CurrStr-1;
TextColor(Black);
TextBackgroud(White);
write(strall1);
end;
3:
begin
TextColor(White);
TextBackgroud(Black);
write(strall3);
CurrStr:=CurrStr-1;
TextColor(Black);
TextBackgroud(White);
write(strall2);
end;
end;
end;
 
Function Menu72;
begin
case (CurrStr) of
1:
begin
TextColor(White);
TextBackgroud(Black);
write(strall1);
CurrStr:=CurrStr+1;
TextColor(Black);
TextBackgroud(White;);
write(strall2);
end;
2:
begin
TextColor(White);
TextBackgroud(Black);
write(strall2);
CurrStr:=CurrStr+1;
TextColor(Black);
TextBackgroud(White);
write(strall3);
end;
end;
end;
 
end.

Помогите плиз
У меня выдает ошибку «Syntax Error, «:» expected but «;» found
Хотя после процедуры «:» ставить не надо.
В чем проблема?

Добавлено через 12 минут
Чуть не забыл. Ошибку выдает в 52 строчке

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



Programming

Эксперт

94731 / 64177 / 26122

Регистрация: 12.04.2006

Сообщений: 116,782

17.01.2012, 01:50

7

Puporev

Почетный модератор

64272 / 47571 / 32739

Регистрация: 18.05.2008

Сообщений: 115,182

17.01.2012, 09:02

2

Цитата
Сообщение от XpycT36
Посмотреть сообщение

Хотя после процедуры «:» ставить не надо

Правильно, но какого вы пишете

Pascal
1
2
3
Function Menu80;
.......................
Function Menu72;

пишите Procedure
кроме того по разному объявлено
в интерфейсе

Pascal
1
function Menu(X,Y: integer):integer;

а в исполнительной части

Pascal
1
Function Menu(X,Y: integer;str1,str2,str3: string):integer;

разное количество параметров.
И еще почти везде в

Pascal
1
TextBackgroud(White);

пропущена буква n в ground



0



XpycT36

0 / 0 / 0

Регистрация: 09.01.2012

Сообщений: 6

17.01.2012, 18:33

 [ТС]

3

ой… моя невнимательность. Спасибо

Добавлено через 1 час 59 минут
У меня еще один вопрос

Если вы еще не догадались, я пишу меню.

Pascal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
Unit SourceModMenu;
 
interface
 
Uses Crt;
 
function Menu(X,Y: integer;str1,str2,str3: string): integer; //Функция для меню
Procedure Menu80; // Процедура для функции Menu. При нажатии стрелкии вверх
Procedure Menu72; // Процедура для функции Menu. При нажатии стрелкии вниз
 
var Choose: integer;
 
implementation
 
var
CurrStr: integer;
strall1: string;
strall2: string;
strall3: string;
Xall: integer;
Yall: integer;
 
Function Menu(X,Y: integer;str1,str2,str3: string):integer;
var
key: char;
CucleEnd: boolean;
begin
Clrscr;
CurrStr:=1;
CucleEnd:=false;
strall1:=str1;
strall2:=str2;
strall3:=str3;
Xall:=X;
Yall:=Y;
GoToXY(X,Y);
TextColor(White);
TextBackground(Black);
write(str1);
GoToXY(X,Y+1);
TextColor(Black);
TextBackground(White);
write(str2);
GoToXY(X,Y+2);
TextColor(Black);
TextBackground(White);
write(str3);
GoToXY(X,Y);
repeat
begin
key:=Readkey;
if key=chr(0) then
key:=Readkey;
if key=chr(80) then
Menu80;
if key=chr(72) then
Menu72;
if key=chr(13) then
begin
CucleEnd:=true;
Menu:=Choose;
end;
end;
until CucleEnd=true;
end;
 
Procedure Menu72;
begin
case (CurrStr) of
2:
begin
TextColor(White);
TextBackground(Black);
write(strall2);
CurrStr:=CurrStr-1;
TextColor(Black);
TextBackground(White);
GoToXY((Xall-1)+CurrStr,Yall);
write(strall1);
end;
3:
begin
TextColor(White);
TextBackground(Black);
write(strall3);
CurrStr:=CurrStr-1;
TextColor(Black);
TextBackground(White);
GoToXY((Xall-1)+CurrStr,Yall);
write(strall2);
end;
end;
end;
 
Procedure Menu80;
begin
case (CurrStr) of
1:
begin
TextColor(White);
TextBackground(Black);
write(strall1);
CurrStr:=CurrStr+1;
TextColor(Black);
TextBackground(White);
GoToXY((Xall-1)+CurrStr,Yall);
write(strall2);
end;
2:
begin
TextColor(White);
TextBackground(Black);
write(strall2);
CurrStr:=CurrStr+1;
TextColor(Black);
TextBackground(White);
GoToXY((Xall-1)+CurrStr,Yall);
write(strall3);
end;
end;
end;
 
end.

У меня программа рисует меню и закрывается. А если я убираю строчку if key=chr(0) then
то все нормально. Но тут еще появляется проблема. Функции для стрелок «вверх и «вниз» не работают (то есть меню не двигается) , хотя я уже много раз перепроверял, все ровно, не могу найти у себя ошибку.



0



Почетный модератор

64272 / 47571 / 32739

Регистрация: 18.05.2008

Сообщений: 115,182

17.01.2012, 19:07

4

Вместо crt напишите wincrt;

Цитата
Сообщение от XpycT36
Посмотреть сообщение

У меня программа рисует меню и закрывается

Ну без программы по одному модулю это не проверить.

Цитата
Сообщение от XpycT36
Посмотреть сообщение

Функции для стрелок «вверх и «вниз» не работают

Попробуй вместо crt написать wincrt



1



XpycT36

0 / 0 / 0

Регистрация: 09.01.2012

Сообщений: 6

18.01.2012, 02:18

 [ТС]

5

Да нет, вы не поняли)) Меню пишу я и функции для стрелок тоже. Я говорю про то что код процедур для стрелок «вверх» «вниз» наверное написан неправильно тк при нажимании на стрелки ничего не происходит. Если что то вот основной код

Pascal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Snake 13.01.12
Program Snake;
 
uses Crt, SourceModTitle, SourceModMenu; //Обязательно подключить модули SourceMod!!!
 
var
Game: integer;
 
begin
Options;
Title;
Game:=Menu(2,2,'Start','Options','Quit');
if Game=1 then
begin
 
end;
end.



0



Puporev

Почетный модератор

64272 / 47571 / 32739

Регистрация: 18.05.2008

Сообщений: 115,182

18.01.2012, 07:04

6

XpycT36, Ты какой-то безрукий, сейчас программа не запускается потому что нет модуля
SourceModTitle.

Добавлено через 1 минуту
Попробуй написать

Pascal
1
2
3
4
5
6
key:=Readkey;
if key=#0 then
key:=Readkey;
if key=#80 then
Menu80;
if key=#72 then



0



0 / 0 / 0

Регистрация: 03.05.2016

Сообщений: 1

03.05.2016, 16:29

7

Здравствуйте! Объясните пожалуйста как сделать задание не понимаю желательно на примерах

Вложения удалены модератором.



0



Почетный модератор

64272 / 47571 / 32739

Регистрация: 18.05.2008

Сообщений: 115,182

03.05.2016, 16:39

8

fdsd223sdsff111, Прочитай Правила форума и подумай. Для каждого задания создай свою тему с адекватным названием и текстом, напечатанным в теме, а не на фотке. Темы создайте в нужном разделе:
Лазарус или Делфи для начинающих.



0



IT_Exp

Эксперт

87844 / 49110 / 22898

Регистрация: 17.06.2006

Сообщений: 92,604

03.05.2016, 16:39

Помогаю со студенческими работами здесь

Unit1.pas(51,0) Fatal: Syntax error, «BEGIN» expected but «end of file» found
Вобщем, мне говорят что у меня ошибка в несуществующей строке.
Пишет мне вот это; unit1.pas(51,0)…

Fatal:syntax error,»UNTIL» expected but «indentifier RESET» found
Написала программы а компилятор выдает ошибку что делать??

program lab6;
uses crt;
type

Ошибка: «sintax error, «OF» expected, but «[» found»
Здравствуйте, в 4 строке компилятор выдаёт ошибку: "sintax error, "OF" expected, but "var…

Syntax error, «:» expected but «(» found
Блин решаю задачу и тут выпала ошибка ‘Syntax error, ":" expected but "(" found’ незнаю как решить…

Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:

8

Topic: problem with Fatal: Syntax error, «;» expected but «:» found  (Read 5227 times)

Hello, I am a beginner in Lazarus and the Pascal language.
my problem is that every time I try to run my program it gives me this error: Fatal: syntax error, «;» expected but found.
in case there is any doubt this is the program.
program division;
var
a,b,c:double;
begin
writeln(‘extra division’);
writeln(‘ingresa el divisor’);
readln(a);
writeln(‘ingresa el dividendo’);
readln(b);
if (b=0) then
begin
writeln(‘math error’);
readln;
end
else
begin
c:a/b;
writeln(‘el resultado de la division es’,c:4:2);
readln;
end;

I would be very grateful to you if you could help me solve this problem.


Logged



Logged


HOMEWORK ???

  1. PROGRAM Division;

  2. VAR dDividend,dDivisor,dQuotient:Double;

  3. BEGIN

  4. Writeln(‘extra division’);

  5. Writeln(‘ingresa el dividendo’);

  6. Readln(dDividend);

  7. Writeln(‘ingresa el divisor’);

  8. Readln(dDivisor);

  9. If (dDivisor = 0)

  10. Then

  11. Begin

  12. Writeln(‘math error’);

  13. Readln;

  14. End

  15. Else

  16. Begin

  17.     dQuotient:= dDividend/dDivisor;

  18. Writeln(‘el resultado de la division es:  ‘,dQuotient:4:2);

  19. Readln;

  20. END;

  21. END.


Logged

Windows 7 Pro (x64 Sp1) & Windows XP Pro (x86 Sp3).



Logged


Hello, I am a beginner in Lazarus and the Pascal language.
my problem is that every time I try to run my program it gives me this error: Fatal: syntax error, «;» expected but found.
in case there is any doubt this is the program.
program division;
var
a,b,c:double;
begin
writeln(‘extra division’);
writeln(‘ingresa el divisor’);
readln(a);
writeln(‘ingresa el dividendo’);
readln(b);
if (b=0) then
begin
writeln(‘math error’);
readln;
end
else
begin
c:a/b;
writeln(‘el resultado de la division es’,c:4:2);
readln;
end;

I would be very grateful to you if you could help me solve this problem.


Logged

One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
———————————————————————
Code is like a joke: If you have to explain it, it’s bad


This line:

  1. c:a/b;

Needs to be changed to this:

  1. c := a/b;

Also, you need to add the following at the bottom of the file to close your 1st ‘begin’ and the unit as a whole:

  1. end.

So, the entire code should look like this:

  1. program division;

  2. var

  3.   a, b, c : double;

  4. begin

  5. WriteLn(‘extra division’);

  6. WriteLn(‘ingresa el divisor’);

  7. ReadLn(a);

  8. WriteLn(‘ingresa el dividendo’);

  9. ReadLn(b);

  10. if (b=0) then

  11. begin

  12. WriteLn(‘math error’);

  13. ReadLn;

  14. end

  15. else

  16. begin

  17.     c := a / b; // <— CHANGED!!!

  18. WriteLn(‘el resultado de la division es’, c:4:2);

  19. ReadLn;

  20. end;

  21. end. // <— ADDED!!!

« Last Edit: June 19, 2020, 08:31:39 pm by Remy Lebeau »


Logged


@Remy Lebeau: almost … one is missing …  :P
You don’t get the flower pot !


Logged

Windows 7 Pro (x64 Sp1) & Windows XP Pro (x86 Sp3).


@Remy Lebeau: almost … one is missing …  :P

Which one?  I don’t see anything missing in the code I posted.


Logged


I don’t see anything missing in the code I posted.

Correct, nothing is missing, but the «WriteLn» order is not optimal…

Divisor (a), Dividend (b), Check b = 0 (Dividend?), Divisor/Dividend ?

In my world you have to do it like this:
Dividend / Divisor = Quotient   :)

As I said, you don’t get the flower pot …  :D


Logged

Windows 7 Pro (x64 Sp1) & Windows XP Pro (x86 Sp3).


Hi!

Dont battle about the poor dividende.

We could teach him the way the C boys do it:
Division by zero is no error. Never.

SetExceptionMask([exZeroDivide, exInvalidOp, exDenormalized, exOverflow, exUnderflow, exPrecision]);
….

You dont have to ask for dividing by zero anymore.
The price you have to pay:
Incorrect results and a system crash every now and then.
We all know that from Windows.

Winni


Logged


Dont battle about the poor dividende.

We could teach him the way the C boys do it:
Division by zero is no error. Never.

I think RAW is referring just to the terminology in the WriteLn’s: Remy’s code asks for the divisor when he means the dividend and viceversa. Just a small oversight ;D


Logged

Turbo Pascal 3 CP/M — Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 — 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.


…code asks for the divisor when he means the dividend and viceversa…

@lucamar: the flowers are all yours …  :)

by the way: no battle at all, just a little hint that the code isn’t optimal …  :)


Logged

Windows 7 Pro (x64 Sp1) & Windows XP Pro (x86 Sp3).


I think RAW is referring just to the terminology in the WriteLn’s: Remy’s code asks for the divisor when he means the dividend and viceversa. Just a small oversight ;D

It is not MY code, it is the OP’s code.  I just fixed the syntax errors, not the logic errors.


Logged


Содержание

  1. Fatal: Syntax error, «.» expected but «;» found
  2. 1 Answer 1
  3. Fatal syntax error expected but found паскаль
  4. Re: Ошибка в коде программы!
  5. Re: Ошибка в коде программы!
  6. Re: Ошибка в коде программы!
  7. Re: Ошибка в коде программы!
  8. Re: Ошибка в коде программы!
  9. Re: Ошибка в коде программы!
  10. Re: Ошибка в коде программы!
  11. Pascal fatal error «;» expected but else founded
  12. 2 Answers 2
  13. Fatal syntax error expected but found паскаль
  14. Почему выдаёт ошибку? Где я накосячила? Ошибка: unit1.pas(120,5) Fatal: Syntax error, «;» expected but «ELSE» found

Fatal: Syntax error, «.» expected but «;» found

1 Answer 1

The reason for this is that your begin s and end s are not balanced; disregarding the opening begin and closing end. for the program’s syntax to be correct, you should have equal numbers of each, but you have 4 begin s and 8 end s.

Obviously, your code is to compute the solutions of a quadratic equation. What I think you should do is to adjust the layout of your code so that it reflects that and then correctly the begin s and end s. In particular, your program is trying to detect whether any of a, b and d is zero and, if so, write a diagnostic message, otherwise calculate the roots by the usual formula.

Unfortunately, your begin s and end s do not reflect that. Either the whole of the block starting d := . needs to be executed or none of it does, so the else on the line before needs to be followed by a begin , as in

(You don’t say which Pascal compiler you are using, but the above fixes two points which are flagged as errors in FreePascal.

If you need more help than that, please ask in a comment.

Btw, there are some grammatical constructs in Pascal implementations where an end can appear without a matching preceding begin such as case . of . end .

Источник

Fatal syntax error expected but found паскаль

Анна Бак » 27.10.2014 17:40:51

Re: Ошибка в коде программы!

Дож » 27.10.2014 18:07:56

Видимо, проблема в том, что Вы отсканировали текст и не почистили от фигни.

Вместо короткого тире − должен знак минус -,
вместо обратной кавычки ’ — знак апострофа ‘.

Re: Ошибка в коде программы!

Анна Бак » 27.10.2014 20:02:42

Дож писал(а): Видимо, проблема в том, что Вы отсканировали текст и не почистили от фигни.

Вместо короткого тире − должен знак минус -,
вместо обратной кавычки ’ — знак апострофа ‘.

Я отсканировала текст только для того, чтобы задать вопрос.
А в Free Pascal вводила все в ручную и все знаки переписывала уже несколько раз, ничего не помогает.

Re: Ошибка в коде программы!

Little_Roo » 27.10.2014 20:40:10

Re: Ошибка в коде программы!

Анна Бак » 27.10.2014 21:35:18

Re: Ошибка в коде программы!

Little_Roo » 27.10.2014 21:38:27

Re: Ошибка в коде программы!

Анна Бак » 27.10.2014 22:11:59

Re: Ошибка в коде программы!

Дож » 27.10.2014 23:28:21

Дож писал(а): Видимо, проблема в том, что Вы отсканировали текст и не почистили от фигни.

Вместо короткого тире − должен знак минус -,
вместо обратной кавычки ’ — знак апострофа ‘.

Я отсканировала текст только для того, чтобы задать вопрос.
А в Free Pascal вводила все в ручную и все знаки переписывала уже несколько раз, ничего не помогает.

Источник

Pascal fatal error «;» expected but else founded

What is causing the fatal error «;» expected but else founded message?

2 Answers 2

Unlike C, in Pascal a semicolon ; separates statements, it does not terminate them, and the then clause requires a single statement. then WriteLn(. ); else is two statements; you want then WriteLn(. ) else .

Let’s take this opportunity to learn how to read and use error messages to your advantage.

The compiler tells you exactly what the error is (it’s a ; before an else , because both of those are mentioned in the error message). It also gives you the exact line number where it’s reporting the error; that’s the number (usually in parentheses right before the error message, like (from Delphi):

[DCC Error] Project2.dpr(14): E2153 ‘;’ not allowed before ‘ELSE’

So the error is happening on line 14 (in my code — your number will be different). Let’s look at that line and a few before and after:

So look at the error message:

That clearly tells you that the ; in the line before the else is the problem (that’s very clear, because it says not allowed), so remove it.

BTW, now you’re going to get another error:

[DCC Error] Project2.dpr(15): E2003 Undeclared identifier: ‘wrtieln’

I think you should be able to figure that one out; again, the compiler gives you the exact line number.

You’re going to get another one, if you’ve posted your entire code:

[DCC Error] Project2.dpr(18): E2029 Statement expected but end of file found

This is because you’ve left out the end. that marks the end of a program file in Pascal. If you’ve not posted your entire code, you may not get it.

It’s important to learn to actually read the words when you get an error message from the compiler. In most languages, the messages are clearly worded, and they all have information you can use to try to figure out (or at least narrow down) the problems in your code.

Источник

Fatal syntax error expected but found паскаль

Есть код. Говорит ошибка
строка 69 (предпоследняя строка)Ожидалось ‘;’

А действительно, что ты хотел сказать этим оператором?

Добавлено 17.04.11, 18:46
После строки

P.S. пиши код с отступами.

Код был написан с отступами. Только, чтобы это увидеть, надо использовать тэги подсветки, а не цитаты.

yana33311, кнопка «CODE=pas», а не QUOTE.

Этого недостаточно. Тут вся структура программы порушена. Что за переменная e в 25-ой строке, где она описана? Есть функция exp, переменной e готовой нет. Как может компилироваться строка №39 (Case K Of), когда K описана как Real? Что за описание переменных внутри Case-а (49 строка)?

Ошибок гораздо больше на самом деле (лень проверять в TP, проверил в FPC):

Источник

Почему выдаёт ошибку? Где я накосячила? Ошибка: unit1.pas(120,5) Fatal: Syntax error, «;» expected but «ELSE» found

procedure TForm1.RadioButton1Change(Sender: TObject);
begin
if radiobutton1.checked then
begin
edit1.text := IntToStr(Bin2Dec(edit1.text));
CS := 10;
s:=edit1.text
end;
else begin
edit1.text := IntToStr(Oct2Dec(edit1.text));
CS := 10;
s:=edit1.text;

Button1.Enabled:=True;
Button2.Enabled:=True;
Button3.Enabled:=True;
Button4.Enabled:=True;
Button5.Enabled:=True;
Button6.Enabled:=True;
Button7.Enabled:=True;
Button8.Enabled:=True;
Button9.Enabled:=True;
Button10.Enabled:=True;
Button11.Enabled:=True;
Button12.Enabled:=True;
Button13.Enabled:=True;
Button15.Enabled:=True;
Button16.Enabled:=True;
Button17.Enabled:=True;
Button18.Enabled:=True;
Button14.Enabled:=True;
Button19.Enabled:=True;
Button20.Enabled:=True;
Button21.Enabled:=True;
Button22.Enabled:=True;
Button23.Enabled:=True;
end;

—-исходный кусок ————
CS := 10;
s:=edit1.text
end;
else begin
————неправильно, д. б. так ——————-
CS := 10;
s:=edit1.text;
end
else begin

З. Ы. внимательнее с синтаксисом. лучше код форматировать отступами, вроде так:
begin
begin
.
end;
end;
сразу ясно какой энд какому бегину принадлежит )))

Источник

Adblock
detector

Ошибка в коде программы!

Модератор: Модераторы

Ошибка в коде программы!

Всем доброго времени суток.
В книге Алексеев Е. Р., Чеснокова О. В., Кучер Т. В. — Free Pascal и Lazarus(2010), есть пример такой программы:

Код: Выделить всё
var a, b, c, d, x1, x2: real;
begin
writeln (’Введите_коэффициенты_квадратного_уравнения’);
readln (a, b, c);
d:=b*b−4*a*c;
if d<0 then
begin
//Если дискриминант отрицателен, то вывод сообщения,
//что действительный корней нет и вычисление комплексных корней.
writeln (’Действительных_корней_нет’);
{Вычисление действительной части комплексных корней.}
x1:=−b/(2*a);
{Вычисление модуля мнимой части комплексных корней.}
x2:=sqrt(abs(d))/(2*a);
writeln ( ’Комплексные_корни_уравнения_’,
a:1:2, ’x^2+’ ,b:1:2, ’x+’ ,c:1:2, ’=0’ );
{Вывод значений комплексных корней в виде x1±ix2}
writeln (x1:1:2, ’+i*(’ ,x2:1:2, ’)’);
writeln (x1:1:2, ’−i*(’ ,x2:1:2, ’)’);
end
else
begin
{иначе вычисление действительных корней x1, x2}
x1:=(−b+sqrt(d))/2/a;
x2:=(−b−sqrt(d))/(2*a);
{и вывод их на экран.}
writeln ( ’Действительные_корни_уравнения_’ ,
a:1:2, ’x^2+’ ,b:1:2, ’x+’ ,c:1:2, ’=0’);
writeln (’X1=’ ,x1:1:2, ’X2=’ ,x2:1:2)
end end.

Когда я начинаю компилировать программу выходить такое сообщение об ошибке:
Fatal: Syntax error, «)» expected but «identifier B» found.
Не могу найти где эта ошибка
КТО-НИБУДЬ, ПОДСКАЖИТЕ!!!

Анна Бак
новенький
 
Сообщения: 13
Зарегистрирован: 11.02.2014 13:23:09

Re: Ошибка в коде программы!

Сообщение Дож » 27.10.2014 18:07:56

Видимо, проблема в том, что Вы отсканировали текст и не почистили от фигни.

Вместо короткого тире − должен знак минус -,
вместо обратной кавычки ’ — знак апострофа ‘.

Аватара пользователя
Дож
энтузиаст
 
Сообщения: 891
Зарегистрирован: 12.10.2008 16:14:47

Re: Ошибка в коде программы!

Сообщение Анна Бак » 27.10.2014 20:02:42

Дож писал(а):Видимо, проблема в том, что Вы отсканировали текст и не почистили от фигни.

Вместо короткого тире − должен знак минус -,
вместо обратной кавычки ’ — знак апострофа ‘.

Я отсканировала текст только для того, чтобы задать вопрос.
А в Free Pascal вводила все в ручную и все знаки переписывала уже несколько раз, ничего не помогает.

Анна Бак
новенький
 
Сообщения: 13
Зарегистрирован: 11.02.2014 13:23:09

Re: Ошибка в коде программы!

Сообщение Little_Roo » 27.10.2014 20:40:10

какая строка с ошибкой?

Аватара пользователя
Little_Roo
энтузиаст
 
Сообщения: 632
Зарегистрирован: 27.02.2009 19:56:36
Откуда: Санкт-Петербург

Re: Ошибка в коде программы!

Сообщение Анна Бак » 27.10.2014 21:35:18

Little_Roo писал(а):какая строка с ошибкой?

В этом-то и проблема. Я не могу найти строчку с ошибкой.
Полный текст ошибки такой:
Zero.pas (15,12) Fatal: Syntax error, «)» expected but «identifier B» found.

Анна Бак
новенький
 
Сообщения: 13
Зарегистрирован: 11.02.2014 13:23:09

Re: Ошибка в коде программы!

Сообщение Little_Roo » 27.10.2014 21:38:27

Анна Бак писал(а):Zero.pas (15,12

Таки строка 15, позиция 12…. :shock:
Но это в ПОЛНОМ тексте кода программы….

Аватара пользователя
Little_Roo
энтузиаст
 
Сообщения: 632
Зарегистрирован: 27.02.2009 19:56:36
Откуда: Санкт-Петербург

Re: Ошибка в коде программы!

Сообщение Анна Бак » 27.10.2014 22:11:59

Little_Roo писал(а):Таки строка 15, позиция 12…. :shock:
Но это в ПОЛНОМ тексте кода программы….

СПАСИБО БОЛЬШОЕ!!! :D :D :D

Анна Бак
новенький
 
Сообщения: 13
Зарегистрирован: 11.02.2014 13:23:09

Re: Ошибка в коде программы!

Сообщение Дож » 27.10.2014 23:28:21

Анна Бак писал(а):

Дож писал(а):Видимо, проблема в том, что Вы отсканировали текст и не почистили от фигни.

Вместо короткого тире − должен знак минус -,
вместо обратной кавычки ’ — знак апострофа ‘.

Я отсканировала текст только для того, чтобы задать вопрос.
А в Free Pascal вводила все в ручную и все знаки переписывала уже несколько раз, ничего не помогает.

Разумно приводить на форуме именно неработающий код, потому что приведённый в первом посте после замены указанных мною символов на правильные благополучно компилируется и запускается.

Аватара пользователя
Дож
энтузиаст
 
Сообщения: 891
Зарегистрирован: 12.10.2008 16:14:47

Re: Ошибка в коде программы!

Сообщение Анна Бак » 28.10.2014 13:48:34

Дож писал(а):Разумно приводить на форуме именно неработающий код, потому что приведённый в первом посте после замены указанных мною символов на правильные благополучно компилируется и запускается.

Спасибо. Постараюсь.

Анна Бак
новенький
 
Сообщения: 13
Зарегистрирован: 11.02.2014 13:23:09


Вернуться в Обучение Free Pascal

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 0

Формулировка задачи:

Unit SourceModMenu;
 
interface
 
Uses Crt;
 
function Menu(X,Y: integer):integer; //Функция для меню
Procedure Menu80; // Процедура для функции Menu. При нажатии стрелкии вверх
Procedure Menu72; // Процедура для функции Menu. При нажатии стрелкии вниз
 
var Choose: integer;
 
implementation
 
var
CurrStr: integer;
strall1: string;
strall2: string;
strall3: string;
 
Function Menu(X,Y: integer;str1,str2,str3: string):integer;
var
key: char;
CucleEnd: boolean;
begin
Clrscr;
CurrStr:=1;
strall1:=str1;
strall2:=str2;
strall3:=str3;
GoToXY(X,Y);
TextColor(Black);
TextBackground(White);
write(str1);
TextColor(White);
TextBackground(Black);
write(str2);
repeat
key:=readkey;
if key=chr(0) then
key:=readkey;
if key=chr(80) then
Menu80;
if key=chr(72) then
Menu72;
if key=chr(13) then
CucleEnd:=true;
until CucleEnd=true;
Menu:=Choose;
end;
 
Function Menu80;
begin
case (CurrStr) of
2:
begin
TextColor(White);
TextBackgroud(Black);
write(strall2);
CurrStr:=CurrStr-1;
TextColor(Black);
TextBackgroud(White);
write(strall1);
end;
3:
begin
TextColor(White);
TextBackgroud(Black);
write(strall3);
CurrStr:=CurrStr-1;
TextColor(Black);
TextBackgroud(White);
write(strall2);
end;
end;
end;
 
Function Menu72;
begin
case (CurrStr) of
1:
begin
TextColor(White);
TextBackgroud(Black);
write(strall1);
CurrStr:=CurrStr+1;
TextColor(Black);
TextBackgroud(White;);
write(strall2);
end;
2:
begin
TextColor(White);
TextBackgroud(Black);
write(strall2);
CurrStr:=CurrStr+1;
TextColor(Black);
TextBackgroud(White);
write(strall3);
end;
end;
end;
 
end.

Помогите плиз
У меня выдает ошибку «Syntax Error, «:» expected but «;» found
Хотя после процедуры «:» ставить не надо.
В чем проблема?

Чуть не забыл. Ошибку выдает в 52 строчке

Код к задаче: «Ошибка «Syntax Error, «:» expected but «;» found»

textual

key:=Readkey;
if key=#0 then
key:=Readkey;
if key=#80 then
Menu80;
if key=#72 then

Полезно ли:

8   голосов , оценка 4.000 из 5

Понравилась статья? Поделить с друзьями:
  • Syntax error expected but const real found
  • Syntax error expected an indented block
  • Syntax error excel vba
  • Syntax error eol while scanning string literal python
  • Syntax error eof while scanning triple quoted string literal