Ошибка выполнения 106 турбо паскаль

grand777

23 / 0 / 0

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

Сообщений: 3

1

14.01.2014, 20:19. Показов 5065. Ответов 5

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


Студворк — интернет-сервис помощи студентам

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
type mas1=array[1..100] of integer;
var a:char; m1,m2,m3:mas1; f1,f2:text; n:byte; i,b:integer;
 
begin
 
assign (f1, 'printer.in');
assign (f2, 'printer.out');
reset (f1);
rewrite (f2);
 
readln (f1, n);
 
 for i:=1 to n do
 begin
 readln (f1, a);
 m1[i]:=ord(a);
 read (f1, m2[i]);
 read (f1, m3[i]);
 end;
 
 while not eof (f1) do
 begin
 read (f1,a);
  for i:=1 to n do begin
  if ord(a)=m1[i] then b:=b+m2[i];
  if ord(a)=m1[i]-26 then b:=b+m3[i]
  end;
 end;
 
write (f2, b);
 
close (f1);
close (f2);
 
end.

printer.in

Pascal
1
2
3
4
5
6
7
5
p 5 6
t 7 8
y 9 10
a 1 2
e 3 4
Petya

Ошибка выполнения 106 по адресу 0000:011D

Помогите, в чём проблема?



0



Супер-модератор

6145 / 2887 / 1299

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

Сообщений: 5,751

Записей в блоге: 1

14.01.2014, 20:46

2

Подпрограммы Read и ReadLn сообщают об этой ошибке, если числовое значение, считанное из текстового файла не соответствует нужному числовому формату.

Проверьте, каждый символ файла printer.in для начала



1



23 / 0 / 0

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

Сообщений: 3

14.01.2014, 21:33

 [ТС]

3

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

Подпрограммы Read и ReadLn сообщают об этой ошибке, если числовое значение, считанное из текстового файла не соответствует нужному числовому формату.

Проверьте, каждый символ файла printer.in для начала

прикрепил printer.in к первому посту

скорее всего ошибка в том что сначала читаю а (символ), потом число, хотя может быть и нет.

как исправить, не подскажите?

Добавлено через 39 минут
Проблема решена. Можно закрывать тему.



0



Супер-модератор

6145 / 2887 / 1299

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

Сообщений: 5,751

Записей в блоге: 1

14.01.2014, 21:35

4

grand777, темы не закрываются. Если не трудно, поделитесь решением проблемы с будущими поколениями. Возможно кому-то пригодится…



0



grand777

23 / 0 / 0

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

Сообщений: 3

14.01.2014, 21:50

 [ТС]

5

путём отладки пришел к такому решению: (добавлен ряд 20 и 21, не обязательно a[i], это просто чтобы символы, которые паскаль берёт откуда то (так и не понял откуда) пропустить)

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
type mas2=array[1..100] of integer;
type mas1=array[1..100] of char;
var d,c:char; m1,m2,m3:mas2; a:mas1; f1,f2:text; n:byte; i,b,code:integer;
 
begin
 
assign (f1, 'printer.in');
assign (f2, 'printer.out');
reset (f1);
rewrite (f2);
 
readln (f1, n);
 
 for i:=1 to n do
 begin
 read (f1, a[i]);
 m1[i]:=ord(a[i]);
 read (f1, m2[i]);
 read (f1, m3[i]);
 read (f1, a[i]);
 read (f1, a[i]);
 end;
 
 while not eof (f1) do
 begin
 read (f1,d);
  for i:=1 to n do begin
  if ord(d)=m1[i]-32 then b:=b+m3[i];
  if ord(d)=m1[i] then b:=b+m2[i];
  end;
 end;
 
write (f2, b);
 
close (f1);
close (f2);
 
end.



0



958 / 577 / 136

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

Сообщений: 7,364

15.01.2014, 00:48

6

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

так и не понял откуда

В конце каждой строки записаны два управляющих символа #10 и #13 — признак конца строки и воззврат каретки. Т.к. чтение было посимвольным, то эти символы Вы тоже читаете.
Кстати, можете, например, в Notepad++ открыть текстовый файл и посмотреть скрытые символы



0



Регистрация   Войти‘;

Авторизация

Логин:

Пароль:

Запомнить меня на этом копьютере

Регистрация
Забыли свой пароль?

  

Справочник |Библиотека |Файлы и загрузки |Уроки |FAQ| Скачать Turbo Pascal Форум

  • Синтаксис языка
  • Типы данных
  • Стандартные модули
  • Процедуры и функции
  • Зарезервированные слова
  • Директивы компилятора
  • Сообщения об ошибках
    • Ошибки выполнения
    • Ошибки компиляции
  • Примеры программ
  • Описание среды разработки

Главная / Справочник / Сообщения об ошибках / Ошибки выполнения

Недопустимый числовой формат.

Описание

Подпрограммы Read и ReadLn сообщают об этой ошибке, если числовое значение, считанное из текстового файла не соответствует нужному числовому формату.

© 2009–2023 Russian Pascal Developer Network.
Техническая площадка: ISBIZ Хостинг

ISBIZ.agency
продвижение сайта

Member Avatar


ddanbe

2,724



Professional Procrastinator



Featured Poster


5 Years Ago

Could you tell me what error 106 means and where in your code it occurs?

Member Avatar


Schol-R-LEA

1,446



Commie Mutant Traitor



Featured Poster


5 Years Ago

As DDanbe said, we’d need to know what ‘error 106’ meant here. However, I think we can elaborate on that to make something of a teachable moment.

First, before I address that, I will point out to you that when you post code samples here, you need to indent every line of the code by at least four spaces, or the formatting won’t be preserved. I suggest reading the docs for the Daniweb version of Markdown for a more detailed explanation.

With that out of the way, let’s get on with the show.

While it isn’t entirely clear without more context, it is safe to guess that the ‘106 error’ is a compiler error message, that is, a report of a problem in the code that indicates a fatal error — something that prevents the compiler from finishing the compilation.

It also could be a compiler warning, which indicates something that could be a mistake, but isn’t serious enough to be a showstopper — something which the compiler isn’t sure is a problem, but thinks you should look into. Or, since you didn’t say when it comes up, it could even be an error message that you get after it is compiled, when the program is running.

But the safe bet is that it is a compiler error message.

This means we’d need to know which compiler you are using. Different compilers — even for the same language — will have different error and warning messages and codes, so we’d have to know where to look the error up in order to figure it out.

There are several Pascal compilers around, the most notable being Delphi, FreePascal, and Gnu Pascal .

Now, Delphi is actually an Integrated Development Environment (IDE) for Object Pascal, which is a different language derived from Pascal, but the Delphi compiler will compile most Standard Pascal code as well, and is sometimes used in courses that teach Pascal (in the same way C++ compilers often double as C compilers). However, the Delphi compiler is a commercial product, so most people have shifted to using the mostly-compatible FreePascal instead.

As the name implies, FreePascal is a free, open-source compiler for Pascal and Object Pascal. It isn’t as refined as Delphi, but it is pretty close, and the limited market interest in Pascal in general means it is a lot more appealing to most people than Delphi. It is often paired with Lazarus IDE, an IDE which emulated the tools found in earlier versions of Delphi.

Gnu Pascal is a part of the Gnu Compiler Collection, being a front-end for the same code generators used by gcc and g++. It isn’t as commonly used as FreePascal, for a variety of reasons, but it is there. It is sometimes used with the Dev-Pascal IDE, but like with all GNU packages, it is really aimed at being used with a general-purpose programmer’s editor such as vim or EMACS.

So, we will need to know which compiler gives an ‘error 106’ message in order to figure this out. Presumably, you know what compiler — or at least what IDE — you are using, so that’s what you would need to tell us.

It would also help if you could tell us the error message itself, and if possible, what part of the code it is pointing to. If you could copy and paste the error message (or make a screen shot of it, though getting the text would be preferable), it should give us a better idea of what it is trying to tell you.

Doing a search on the error message would make sense too, but without knowing the compiler, it might be of limited use. So, Let Me Google That For You, and see what it gives us.

/me reads search results OK, it seems to be a FreePascal ‘invalid numeric format’ error. Oh, it could be some ancient version of Turbo Pascal with a ‘string expression expected’ error, but honestly, if your professor has you using an MS-DOS compiler from thirty years ago, the only solution is to get the other students together, walk out of the course en masse, and complain to the Dean of the university about the incompetent who is teaching the class.

That’s about as much as we really can say, without more information. We could make some guesses, but that’s all they would be, so it would be better if we refrain from that.

Hopefully, this post has taught you a few important lessons about doing the necessary research on your own before asking for help, and providing enough information when you do ask for help. Good luck with that, because no one here is going to give you this much hand-holding ever again.

Edited

5 Years Ago
by Schol-R-LEA because:

clarification re: GCC

Member Avatar


rproffitt

2,424



«Nothing to see here.»



Moderator


5 Years Ago

106 Invalid numeric format

Since we don’t know what you typed in response to each question it appears your code is what we call fragile. Blows up when you input a numeric but answer with a character.

Member Avatar

1 Year Ago

Screenshot_2022-01-17_225355.png

what is this error?
please answer soon!

Member Avatar


Schol-R-LEA

1,446



Commie Mutant Traitor



Featured Poster


1 Year Ago

As Rproffitt said, please make your own new threads rather than resurrecting long-dead ones.

As for the error code, that was explained in detail earlier in this thread: it indicates that you tried to read a number from a file, and got something other than a number, as defined here. The likely solution is to add a check for an end-of-file in the loop, using the function eof().

Though from the screenshot, you might be using Turbo Pascal, where the error indicates a malformed string. The correct solution to this is Don’t Use Turbo Pascal.

Edited

1 Year Ago
by Schol-R-LEA

I’m still fairly new to Pascal and I’m getting these errors and I’m not sure why. Some help would be greatly appreciated.

Runtime error 106 at $004015DFF
                     $004015DF
                     $004016D2
                     $004016FD
                     $004078D1

This is my code if you guys want to take a look.

program BasicReadWrite;

type
  ArrayOfPersons = record
    name: String;
    age: String; 
  end;

procedure WriteLinesToFile(var myFile: TextFile);
begin
  WriteLn(myFile, 5);
  WriteLn(myFile, 'Fred Smith');
  WriteLn(myFile, 28);
  WriteLn(myFile, 'Jill Jones');
  WriteLn(myFile, 54);
  WriteLn(myFile, 'John Doe');
  WriteLn(myFile, 15);
  WriteLn(myFile, 'Samantha Pritchard');
  WriteLn(myFile, 19);
  WriteLn(myFile, 'Hans Fredrickson');
  WriteLn(myFile, 77);
end;

procedure PrintRecordsToTerminal(personArray: ArrayOfPersons; count: 
  Integer);
begin
  WriteLn('Person name: ', personArray.name);
  WriteLn('Age: ', personArray.age);
end;

procedure ReadLinesFromFile(var myFile: TextFile);
var 
  p: ArrayOfPersons;
  number: Integer;
begin
  number := 0;
  while number <= 19 do
  begin
    ReadLn(myFile, number);
    ReadLn(myFile, p.name[number]);
    ReadLn(myFile, p.age);
    number := number + 1;
  end;
end;

>
Ошибка
, Ошибка в програме.



Сообщ.
#1

,
23.11.09, 17:54

    ExpandedWrap disabled

      program треугол;

      uses crt;

      function провер(x,y,z:integer):boolean;

      begin

      if(abs(x-y)<z)and(x+y>z) then провер:=true

      else провер:=false;

      end;

      function площ(x,y,z:integer):real;

      var p:integer;

      begin

      p:=(x+y+z)div 2;

      площ:=sqrt(p*(p-x)*(p-y)*(p-z));

      end;

      var f:text;

          n,i,sk,a,b,c:integer;

      begin

      clrscr;

      randomize;

      assign(f,’treug.txt’);

      rewrite(f);

      write(‘Сколько будет треугольников? n=’);

      readln(n);

      for i:=1 to n do

       begin

        a:=random(10)+1;

        write(f,a);

        b:=random(10)+1;

        write(f,’ ‘,b);

        c:=random(10)+1;

        write(f,’ ‘,c);

        writeln(f,»);

       end;

      close(f);

      reset(f);

      sk:=0;i:=1;

      while not eof(f) do

       begin

        read(f,a);

        read(f,b);

        read(f,c);

        i:=i+1;

        if провер(a,b,c) then

          begin

           sk:=sk+1;

           writeln(i:2,’ — ‘,площ(a,b,c):5:2)

          end

        else writeln(i:2,’ — это не треугольник!’ );

       end;

      writeln;

      writeln(‘Треугольников = ‘,sk);

      close(f);

      readln;

      end.

    Данная программа мне постоянно выдает ошибку №106 — плохой формат числа. В чем дело?

    Сообщение отредактировано: volvo877 — 23.11.09, 19:40


    Polinom2686



    Сообщ.
    #2

    ,
    23.11.09, 18:26

      Senior Member

      ****

      Рейтинг (т): 13

      Как сказал бы мой преподаватель по системам коммутации (хорошая женщина :) )

      KIKSa, ты гениальный ребенок!

      Цитата

      program треугол;
      function провер(x,y,z:integer):boolean;
      function площ(x,y,z:integer):real;

      Почему название программы и функций русскими буквами пишешь?

      Добавлено 23.11.09, 18:28

      Цитата Polinom2686 @ 23.11.09, 18:26

      Данная программа мне постоянно выдает ошибку №106 — плохой формат числа. В чем дело?

      Ошибка ведь возникает при компиляции? Компилятор должен указать место ошибки. Что показывает компилятор?

      Сообщение отредактировано: Polinom2686 — 23.11.09, 18:28


      Polinom2686



      Сообщ.
      #3

      ,
      23.11.09, 18:40

        Senior Member

        ****

        Рейтинг (т): 13

        ExpandedWrap disabled

          program треугол;

          uses crt;

          function провер(x,y,z:integer):boolean;

          begin

          if(abs(x-y)<z)and(x+y>z) then провер:=true

                                   else провер:=false;

          end;

          function площ(x,y,z:integer):real;

          var p:integer;

          begin

          p:=(x+y+z)div 2;

          площ:=sqrt(p*(p-x)*(p-y)*(p-z));

          end;

          var f:text;

          n,i,sk,a,b,c:integer;

          begin

          clrscr;

          randomize;

          assign(f,’treug.txt’);

          rewrite(f);

          write(‘Сколько будет треугольников? n=’);

          readln(n);

          for i:=1 to n do begin

                           a:=random(10)+1;

                           write(f,a);

                           b:=random(10)+1;

                           write(f,’ ‘,b);

                           c:=random(10)+1;

                           write(f,’ ‘,c);

                           writeln(f,»);

                           end;

          close(f);

          reset(f);

          sk:=0;i:=1;

          while not eof(f) do begin

                              read(f,a); {Посмотри на эту строку}

                              read(f,b);

                              read(f,c);

                              i:=i+1;

                              if провер(a,b,c) then begin

                                                    sk:=sk+1;

                                                    writeln(i:2,’ — ‘,площ(a,b,c):5:2)

                                                    end

                                               else writeln(i:2,’ — это не треугольник!’ );

                              end;

          writeln;

          writeln(‘Треугольников = ‘,sk);

          close(f);

          readln;

          end.

        Как я понял, ты используешь FreePascal. Так?

        Перевод сообщения ошибки (Google’вский)

        106 Invalid numeric format Reported when a non-numeric value is read from a text file, when a numeric value was expected.

        106 Неправильная числовой формат сообщается, когда не-числовые значения считываются из текстового файла, когда ожидается числовое значение.

        Что содержит файл treug.txt ?


        KIKSa



        Сообщ.
        #4

        ,
        23.11.09, 18:45

          Всякие треугол в названии появились во время перевода. Первоначально програма писалась латиницей на литовском языке. Что касается ошибки — выскакивает окно — ошибка №106 — плохой формат числа(это тоже перевод). Внизу ничего не пишут — программа скомпилирована и все.
          Оригинал — может пригодится…

          ExpandedWrap disabled

            program trikampiai;

            uses crt;

            function tikr(x,y,z:integer):boolean;

            begin

            if(abs(x-y)<z)and(x+y>z) then tikr:=true

            else tikr:=false;

            end;

            function plotas(x,y,z:integer):real;

            var p:integer;

            begin

            p:=(x+y+z)div 2;

            plotas:=sqrt(p*(p-x)*(p-y)*(p-z));

            end;

            var f:text;

                n,i,sk,a,b,c:integer;

            begin

            clrscr;

            randomize;

            assign(f,’trikamp.txt’);

            rewrite(f);

            write(‘Kiek bus trikampiu? n=’);

            readln(n);

            for i:=1 to n do

             begin

              a:=random(10)+1;

              write(f,a);

              b:=random(10)+1;

              write(f,’ ‘,b);

              c:=random(10)+1;

              write(f,’ ‘,c);

              writeln(f,»);

             end;

            close(f);

            reset(f);

            sk:=0;i:=1;

            while not eof(f) do

             begin

              read(f,a);

              read(f,b);

              read(f,c);

              i:=i+1;

              if tikr(a,b,c) then

                begin

                 sk:=sk+1;

                 writeln(i:2,’ — ‘,plotas(a,b,c):5:2)

                end

              else writeln(i:2,’ — tai ne trikampis!’ );

             end;

            writeln;

            writeln(‘Trikampiu yra = ‘,sk);

            close(f);

            readln;

            end.

          Сообщение отредактировано: volvo877 — 23.11.09, 19:40


          Polinom2686



          Сообщ.
          #5

          ,
          23.11.09, 18:58

            Senior Member

            ****

            Рейтинг (т): 13

            Цитата Polinom2686 @ 23.11.09, 18:40

            Что содержит файл treug.txt ?

            А что с этим вопросом?

            Добавлено 23.11.09, 18:59
            Прикрепи этот файл к своему сообщению.


            KIKSa



            Сообщ.
            #6

            ,
            23.11.09, 19:05

              Этот файл создается программой и в него записывает длину сторон треугольников. 1-ая строка — 1-й треугольник и т.д.


              Polinom2686



              Сообщ.
              #7

              ,
              23.11.09, 19:26

                Senior Member

                ****

                Рейтинг (т): 13

                Твой исходник отработал без ошибок.

                Добавлено 23.11.09, 19:30
                Я его немного изменил.

                ExpandedWrap disabled

                  program trikampiai;

                  uses crt;

                  function tikr(x,y,z:integer):boolean;

                  begin

                  if(abs(x-y)<z)and(x+y>z) then tikr:=true

                  else tikr:=false;

                  end;

                  function plotas(x,y,z:integer):real;

                  var p:integer;

                  begin

                  p:=(x+y+z)div 2;

                  plotas:=sqrt(p*(p-x)*(p-y)*(p-z));

                  end;

                  var f:text;

                  n,i,a,b,c:integer;

                  begin

                  clrscr;

                  randomize;

                  assign(f,’trikamp.txt’);

                  rewrite(f);

                  write(‘Kiek bus trikampiu? n=’);

                  readln(n);

                  for i:=1 to (n-1) do begin

                                       a:=random(10)+1;

                                       write(f,a);

                                       b:=random(10)+1;

                                       write(f,’ ‘,b);

                                       c:=random(10)+1;

                                       writeLn(f,’ ‘,c);

                                       end;

                  a:=random(10)+1;

                  write(f,a);

                  b:=random(10)+1;

                  write(f,’ ‘,b);

                  c:=random(10)+1;

                  write(f,’ ‘,c);

                  close(f);

                  reset(f);

                  i:=0;

                  while not eof(f) do begin

                                      read(f,a);

                                      read(f,b);

                                      read(f,c);

                                      Inc(i);

                                      if tikr(a,b,c) then begin

                                                          writeln(i:2,’ — ‘,plotas(a,b,c):5:2)

                                                          end

                                                     else writeln(i:2,’ — tai ne trikampis!’ );

                                      end;

                  writeln;

                  writeln(‘Trikampiu yra = ‘,i);

                  close(f);

                  readln;

                  end.

                Добавлено 23.11.09, 19:47

                ExpandedWrap disabled

                  for i:=1 to n do begin

                                   a:=random(10)+1;

                                   write(f,a);

                                   b:=random(10)+1;

                                   write(f,’ ‘,b);

                                   c:=random(10)+1;

                                   write(f,’ ‘,c);

                                   writeln(f,»);  

                                   end;

                Подозреваю, что ошибка возникала из-за последнего writeln(f,»);
                Программа записывала в файл не n строк с цифрами, а n+1. Причем последняя строка была пустой.

                ExpandedWrap disabled

                  while not eof(f) do begin

                                      read(f,a);

                                      read(f,b);

                                      read(f,c);

                                      i:=i+1;

                                      if tikr(a,b,c) then begin

                                                          sk:=sk+1;

                                                          writeln(i:2,’ — ‘,plotas(a,b,c):5:2)

                                                          end

                                                     else writeln(i:2,’ — tai ne trikampis!’ );

                  end;

                А потом ты считывал из файла не n строк, а n+1. Последняя строка была пустой. Вот и возникала ошибка.

                Добавлено 23.11.09, 19:48

                Цитата Polinom2686 @ 23.11.09, 18:40

                Перевод сообщения ошибки (Google’вский)

                106 Invalid numeric format Reported when a non-numeric value is read from a text file, when a numeric value was expected.

                106 Неправильная числовой формат сообщается, когда не-числовые значения считываются из текстового файла, когда ожидается числовое значение.

                Сообщение отредактировано: Polinom2686 — 23.11.09, 19:48


                KIKSa

                  


                Сообщ.
                #8

                ,
                24.11.09, 07:40

                  Спасибо, здорово помог. Я с этой программой 2ую неделю воюю. К сожалению мои познания Паскаля остались где-то в районе процедур и функций и чем дальше в лес тем толще партизаны


                  Polinom2686



                  Сообщ.
                  #9

                  ,
                  24.11.09, 12:39

                    Senior Member

                    ****

                    Рейтинг (т): 13

                    Да пожалуйста. ;)

                    Понравилась статья? Поделить с друзьями:

                    Не пропустите эти материалы по теме:

                  • Яндекс еда ошибка привязки карты
                  • Ошибка выжившего цитаты
                  • Ошибка выплаты backit
                  • Ошибка выжившего философия
                  • Ошибка вылетает инстаграм

                  • 0 0 голоса
                    Рейтинг статьи
                    Подписаться
                    Уведомить о
                    guest

                    0 комментариев
                    Старые
                    Новые Популярные
                    Межтекстовые Отзывы
                    Посмотреть все комментарии