An electronic clock is given, and you need to make sure that the user can score time on his own, there are 7 illuminated indicators on the clock.
I do not know where the error is. When running

Program1.pas (37): A 'procedure' was encountered, and an operator was expected

program TIME; var a,b,c,d,e,f,g:boolean; procedure zero; begin writeln(' a'); writeln('__'); writeln('f| |b'); writeln(' g'); writeln('__'); writeln('e| |c'); writeln('__'); writeln(' d'); writeln('Индикатор a? Да - 1, нет - 0.'); readln(a); writeln('Индикатор f? Да - 1, нет - 0.'); readln(f); writeln('Индикатор b? Да - 1, нет - 0.'); readln(b); writeln('Индикатор g? Да - 1, нет - 0.'); readln(g); writeln('Индикатор e? Да - 1, нет - 0.'); readln(e); writeln('Индикатор c? Да - 1, нет - 0.'); readln(c); writeln('Индикатор d? Да - 1, нет - 0.'); readln(d); begin if ((a=1) and (f=1) and (b=1) and (g=0) and (e=1) and (c=1) and (d=1)) then writeln('__'); writeln('| |'); writeln('| |'); writeln('__'); writeln('Цифра 0'); end; procedure one; begin if ((a=0) and (f=0) and (b=1) and (g=0) and (e=0) and (c=1) and (d=0)) then writeln(' |'); writeln(' |'); writeln('Цифра 1'); end; procedure two; begin if ((a=1) and (f=0) and (b=1) and (g=1) and (e=1) and (c=0) and (d=1)) then writeln('__'); writeln(' |'); writeln('__'); writeln('| '); writeln('__'); writeln('Цифра 2'); end; procedure three; begin if ((a=1) and (f=0) and (b=1) and (g=0) and (e=0) and (c=1) and (d=1)) then writeln('__'); writeln(' |'); writeln('__'); writeln(' |'); writeln('__'); writeln('Цифра 3'); end; procedure four; begin if ((a=0) and (f=1) and (b=1) and (g=1) and (e=0) and (c=1) and (d=0)) then writeln('| |'); writeln('__'); writeln(' |'); writeln('Цифра 4'); end; procedure five; begin if ((a=1) and (f=1) and (b=0) and (g=1) and (e=0) and (c=1) and (d=1)) then writeln('__'); writeln('| '); writeln('__'); writeln(' |'); writeln('__'); writeln('Цифра 5'); end; procedure six; begin if ((a=1) and (f=1) and (b=0) and (g=1) and (e=1) and (c=1) and (d=1)) then writeln('__'); writeln('| '); writeln('__'); writeln('| |'); writeln('__'); writeln('Цифра 6'); end; procedure seven; begin if ((a=1) and (f=0) and (b=1) and (g=0) and (e=0) and (c=1) and (d=0)) then writeln('__'); writeln(' |'); writeln(' |'); writeln('Цифра 7'); end; procedure eight; begin if ((a=1) and (f=1) and (b=1) and (g=1) and (e=1) and (c=1) and (d=1)) then writeln('__'); writeln('| |'); writeln('__'); writeln('| |'); writeln('__'); writeln('Цифра 8'); end; procedure nine; begin if ((a=1) and (f=1) and (b=1) and (g=1) and (e=0) and (c=1) and (d=1)) then writeln('__'); writeln('| |'); writeln('__'); writeln(' |'); writeln('__'); writeln('Цифра 9'); end; end. 

Closed due to the fact that off-topic participants Abyx , aleksandr barakin , Pavel Mayorov , Nicolas Chabanovsky 1 Feb '16 at 7:24 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - aleksandr barakin, Nicolas Chabanovsky
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • Comments are not intended for extended discussion; conversation moved to chat . - Nicolas Chabanovsky

1 answer 1

The main error is that procedures are defined, but the body of the main program is not defined, namely there is no construction

 begin end. 

Apparently, it should have entered parameters, therefore this code should have been the main program.

 begin writeln(' a'); writeln('__'); writeln('f| |b'); writeln(' g'); writeln('__'); writeln('e| |c'); writeln('__'); writeln(' d'); writeln('Индикатор a? Да - 1, нет - 0.'); readln(a); writeln('Индикатор f? Да - 1, нет - 0.'); readln(f); writeln('Индикатор b? Да - 1, нет - 0.'); readln(b); writeln('Индикатор g? Да - 1, нет - 0.'); readln(g); writeln('Индикатор e? Да - 1, нет - 0.'); readln(e); writeln('Индикатор c? Да - 1, нет - 0.'); readln(c); writeln('Индикатор d? Да - 1, нет - 0.'); readln(d); 

Further, there is no call of the described procedures, therefore after entering the program will simply end and will not output anything.

To solve, you need to add calls to these procedures to the main program.


The following error:

 if ((a=1) and (f=0) and (b=1) and (g=0) and (e=0) and (c=1) and (d=0)) 

In conditions there is an attempt to compare a Boolean variable and an integer, but you get the following error

The operation '=' does not apply to the types boolean and integer

To avoid this, you can omit the comparison, since variables are already of type boolean, to verify that the variable is true is enough to use the variable itself, and to check that it is false , you need to use the not operator. Thus, the above expression will take the form

 if (a and not f and b and not g and not e and c and not d) 

Similarly, the remaining conditions should be converted.
But you will have to enter not just 1 , 0 , but true , false .
Instead, you can simply change the type of variables to Integer.


The following error:

if...then construction implies that after then is a single expression, thus for the following code

 if ((a=1) and (f=1) and (b=1) and (g=1) and (e=0) and (c=1) and (d=1)) then writeln('__'); writeln('| |'); writeln('__'); writeln(' |'); writeln('__'); writeln('Цифра 9'); 

the condition will affect only the first writeln , the rest will always be fulfilled.

To avoid this, you must use the compound begin...end; operator begin...end; in this way

 if ((a=1) and (f=1) and (b=1) and (g=1) and (e=0) and (c=1) and (d=1)) then begin writeln('__'); writeln('| |'); writeln('__'); writeln(' |'); writeln('__'); writeln('Цифра 9'); end; 

The resulting code might look like this:

 program TIME; var a,b,c,d,e,f,g:boolean; procedure zero; begin if (a and f and b and not g and e and c and d) then begin writeln('__'); writeln('| |'); writeln('| |'); writeln('__'); writeln('Цифра 0'); end; end; procedure one; begin if (not a and not f and b and not g and not e and c and not d) then begin writeln(' |'); writeln(' |'); writeln('Цифра 1'); end; end; procedure two; begin if (a and not f and b and g and e and not c and d) then begin writeln('__'); writeln(' |'); writeln('__'); writeln('| '); writeln('__'); writeln('Цифра 2'); end; end; procedure three; begin if ( a and not f and b and not g and not e and c and d) then begin writeln('__'); writeln(' |'); writeln('__'); writeln(' |'); writeln('__'); writeln('Цифра 3'); end; end; procedure four; begin if ( not a and f and b and g and not e and c and not d) then begin writeln('| |'); writeln('__'); writeln(' |'); writeln('Цифра 4'); end; end; procedure five; begin if (a and f and not b and g and not e and c and d) then begin writeln('__'); writeln('| '); writeln('__'); writeln(' |'); writeln('__'); writeln('Цифра 5'); end; end; procedure six; begin if (a and f and not b and g and e and c and d) then begin writeln('__'); writeln('| '); writeln('__'); writeln('| |'); writeln('__'); writeln('Цифра 6'); end; end; procedure seven; begin if (a and not f and b and not g and not e and c and not d) then begin writeln('__'); writeln(' |'); writeln(' |'); writeln('Цифра 7'); end; end; procedure eight; begin if (a and f and b and g and e and c and d) then begin writeln('__'); writeln('| |'); writeln('__'); writeln('| |'); writeln('__'); writeln('Цифра 8'); end; end; procedure nine; begin if (a and f and b and g and not e and c and d) then begin writeln('__'); writeln('| |'); writeln('__'); writeln(' |'); writeln('__'); writeln('Цифра 9'); end; end; // Основная программа begin writeln(' a'); writeln('__'); writeln('f| |b'); writeln(' g'); writeln('__'); writeln('e| |c'); writeln('__'); writeln(' d'); writeln('Индикатор a? Да - true, нет - false.'); readln(a); writeln('Индикатор f? Да - true, нет - false.'); readln(f); writeln('Индикатор b? Да - true, нет - false.'); readln(b); writeln('Индикатор g? Да - true, нет - false.'); readln(g); writeln('Индикатор e? Да - true, нет - false.'); readln(e); writeln('Индикатор c? Да - true, нет - false.'); readln(c); writeln('Индикатор d? Да - true, нет - false.'); readln(d); one; two; three; four; five; six; seven; eight; nine; end.