Run error 104 lazarus

error messages Contents Errors during compilation Unless the error identifies itself as an internal compiler error, it is unlikely that the error is caused by a bug in the compiler or its runtime library. Syntax errors are almost always due to incorrect code. Refer to the FPC Parser Messages documentation for a listing of […]

Содержание

  1. error messages
  2. Contents
  3. Errors during compilation
  4. Errors during program execution
  5. If the bug is already known
  6. If the bug is not already known
  7. RunError
  8. RunError

error messages

Contents

Errors during compilation

Unless the error identifies itself as an internal compiler error, it is unlikely that the error is caused by a bug in the compiler or its runtime library. Syntax errors are almost always due to incorrect code. Refer to the FPC Parser Messages documentation for a listing of the various Error and Warning messages produced by the FPC Parser along with explanations of them.

If you encounter an error while compiling your code and are unable to resolve it yourself, please use the FPC and Lazarus Forums, write to the Lazarus or Free Pascal mailing list or join the #fpc or #lazarus-ide IRC channel. The problem may then be solved more quickly.

If an error is encountered during compilation, the compiler does not generate an executable program. See further compile time errors.

Errors during program execution

The Free Pascal Compiler inserts code to detect a large number of error situations which might occur during program execution (eg divide by zero). If such an error situation occurs, the standard run-time library will terminate the program and print a runtime error number and the address at which the error occurred. See further runtime errors.

If you encounter a runtime error while running your program and are unable to resolve it yourself, please use the FPC and Lazarus Forums, write to the Lazarus or Free Pascal mailing list or join the #fpc or #lazarus-ide IRC channel.

If the bug is already known

Use the FPC and Lazarus Bug Tracker’s search capabilities.

Known issues. Tip: If you are experiencing problems, for example with TEdit.SelStart -> try searching «SelStart» (in quotes). If the bug is known:

  • reopen if the issue is resolved or the issue is closed — use the Reopen Issue button.
  • add your own note to the discussion if you received this error in another situation.

To observe any changes to your bug report — use the Monitor Issue button.

Note: You need to login to your account: Login/Create an account.

If the bug is not already known

  1. Go to the FPC and Lazarus Bug Tracker.
  2. You must be logged in: Login/Create account.
  3. Visit Report Issue. Fill in as many fields as possible. The more accurate the better.
  • The OS and Product Version fields are especially important. If the data is not enough, they will not help you! Don’t forget to mention the system features (big endian or 64-bit).
  • It is often helpful to send in a small test program to resolve the problem as soon as possible.
  • If you find graphic artifacts, it would not be superfluous to send a screenshot (in png or jpeg, but not in BMP!).
  • If it fails, try creating a backtrace. More information — Creating a Backtrace with GDB.
  • If possible, observe the behaviour of the buggy program on different platforms or with different widgetsets.

It is also possible to get a bug fixed by paying for a solution, see Bounties.

Источник

RunError

A RunError is a low-level error emitted by the Free Pascal Run Time Library. In Lazarus, RunErrors are raised as exceptions.

# Short description Explanation
1 Invalid function number An invalid operating system call was attempted.
2 File not found Reported when trying to erase, rename or open a non-existent file.
3 Path not found Reported by the directory handling routines when a path does not exist or is invalid. Also reported when trying to access a non-existent file.
4 Too many open files The maximum number of files currently opened by your process has been reached. Certain operating systems limit the number of files which can be opened concurrently, and this error can occur when this limit has been reached.
5 File access denied Permission to access the file is denied. This error might be caused by one of several reasons:

  • Trying to open for writing a file which is read-only, or which is actually a directory.
  • File is currently locked or used by another process.
  • Trying to create a new file, or directory while a file or directory of the same name already exists.
  • Trying to read from a file which was opened in write-only mode.
  • Trying to write from a file which was opened in read-only mode.
  • Trying to remove a directory or file while it is not possible.
  • No permission to access the file or directory.
6 Invalid file handle If this happens, the file variable you are using is trashed; it indicates that your memory is corrupted.
12 Invalid file access code Reported when a reset or rewrite is called with an invalid FileMode value.
15 Invalid drive number The number given to the Getdir or ChDir function specifies a non-existent disk.
16 Cannot remove current directory Reported when trying to remove the currently active directory.
17 Cannot rename across drives You cannot rename a file such that it would end up on another disk or partition.
100 Disk read error An error occurred when reading from disk. Typically happens when you try to read past the end of a file.
101 Disk write error Reported when the disk is full, and you’re trying to write to it.
102 File not assigned This is reported by Reset, Rewrite, Append, Rename and Erase, if you call them with an unassigned file as a parameter.
103 File not open Reported by the following functions : Close, Read, Write, Seek, EOf, FilePos, FileSize, Flush, BlockRead, and BlockWrite if the file is not open.
104 File not open for input Reported by Read, BlockRead, Eof, Eoln, SeekEof or SeekEoln if the file is not opened with Reset.
105 File not open for output Reported by write if a text file isn’t opened with Rewrite.
106 Invalid numeric format Reported when a non-numeric value is read from a text file, and a numeric value was expected.
107 Invalid enumeration Reported when a text representation of an enumerated constant cannot be created in a call to str or write(ln).
150 Disk is write-protected (Critical error)
151 Bad drive request struct length (Critical error)
152 Drive not ready (Critical error)
154 CRC error in data (Critical error)
156 Disk seek error (Critical error)
157 Unknown media type (Critical error)
158 Sector Not Found (Critical error)
159 Printer out of paper (Critical error)
160 Device write fault (Critical error)
161 Device read fault (Critical error)
162 Hardware failure (Critical error)
200 Division by zero The application attempted to divide a number by zero.
201 Range check error If you compiled your program with range checking on, then you can get this error in the following cases:

  1. An array was accessed with an index outside its declared range.
  2. Trying to assign a value to a variable outside its range (for instance an enumerated type).
202 Stack overflow error The stack has grown beyond its maximum size (in which case the size of local variables should be reduced to avoid this error), or the stack has become corrupt. This error is only reported when stack checking is enabled.
203 Heap overflow error The heap has grown beyond its boundaries. This is caused when trying to allocate memory explicitly with New, GetMem or ReallocMem, or when a class or object instance is created and no memory is left. Please note that, by default, Free Pascal provides a growing heap, i.e. the heap will try to allocate more memory if needed. However, if the heap has reached the maximum size allowed by the operating system or hardware, then you will get this error.
204 Invalid pointer operation You will get this in several cases:

  • if you call Dispose or Freemem with an invalid pointer
  • in case New or GetMem is called, and there is no more memory available. The behavior in this case depends on the setting of ReturnNilIfGrowHeapFails. If it is True, then Nil is returned. if False, then runerror 204 is raised.
205 Floating point overflow You are trying to use or produce real numbers that are too large.
206 Floating point underflow You are trying to use or produce real numbers that are too small.
207 Invalid floating point operation Can occur if you try to calculate the square root or logarithm of a negative number.
210 Object not initialized When compiled with range checking on, a program will report this error if you call a virtual method without having called its object’s constructor.
211 Call to abstract method Your program tried to execute an abstract virtual method. Abstract methods should be overridden, and the overriding method should be called.
212 Stream registration error This occurs when an invalid type is registered in the objects unit.
213 Collection index out of range You are trying to access a collection item with an invalid index (objects unit).
214 Collection overflow error The collection has reached its maximal size, and you are trying to add another element (objects unit).
215 Arithmetic overflow error This error is reported when the result of an arithmetic operation is outside of its supported range. Contrary to Turbo Pascal, this error is only reported for 32-bit or 64-bit arithmetic overflows. This is due to the fact that everything is converted to 32-bit or 64-bit before doing the actual arithmetic operation.
216 General Protection fault The application tried to access invalid memory space. This can be caused by several problems:

  1. Dereferencing a nil pointer.
  2. Trying to access memory which is out of bounds (for example, calling move with an invalid length).
217 Unhandled exception occurred An exception occurred, and there was no exception handler present. The sysutils unit installs a default exception handler which catches all exceptions and exits gracefully.
218 Invalid value specified Error 218 occurs when an invalid value was specified to a system call, for instance when specifying a negative value to a seek() call.
219 Invalid typecast Thrown when an invalid typecast is attempted on a class using the as operator. This error is also thrown when an object or class is typecast to an invalid class or object and a virtual method of that class or object is called. This last error is only detected if the -CR compiler option is used.
222 Variant dispatch error No dispatch method to call from variant.
223 Variant array create The variant array creation failed. Usually when there is not enough memory.
224 Variant is not an array This error occurs when a variant array operation is attempted on a variant which is not an array.
225 Var Array Bounds check error This error occurs when a variant array index is out of bounds.
227 Assertion failed error An assertion failed, and no AssertErrorProc procedural variable was installed.
229 Safecall error check This error occurs is a safecall check fails, and no handler routine is available.
231 Exception stack corrupted This error occurs when the exception object is retrieved and none is available.
232 Threads not supported Thread management relies on a separate driver on some operating systems (notably, Unixes). The unit with this driver needs to be specified on the uses clause of the program, preferably as the first unit (cthreads on unix).

Add in the top of the first Pascal unit (usually the project .lpr file)

Источник

RunError

A RunError is a low-level error emitted by the Free Pascal Run Time Library. In Lazarus, RunErrors are raised as exceptions.

# Short description Explanation
1 Invalid function number An invalid operating system call was attempted.
2 File not found Reported when trying to erase, rename or open a non-existent file.
3 Path not found Reported by the directory handling routines when a path does not exist or is invalid. Also reported when trying to access a non-existent file.
4 Too many open files The maximum number of files currently opened by your process has been reached. Certain operating systems limit the number of files which can be opened concurrently, and this error can occur when this limit has been reached.
5 File access denied Permission to access the file is denied. This error might be caused by one of several reasons:

  • Trying to open for writing a file which is read-only, or which is actually a directory.
  • File is currently locked or used by another process.
  • Trying to create a new file, or directory while a file or directory of the same name already exists.
  • Trying to read from a file which was opened in write-only mode.
  • Trying to write from a file which was opened in read-only mode.
  • Trying to remove a directory or file while it is not possible.
  • No permission to access the file or directory.
6 Invalid file handle If this happens, the file variable you are using is trashed; it indicates that your memory is corrupted.
12 Invalid file access code Reported when a reset or rewrite is called with an invalid FileMode value.
15 Invalid drive number The number given to the Getdir or ChDir function specifies a non-existent disk.
16 Cannot remove current directory Reported when trying to remove the currently active directory.
17 Cannot rename across drives You cannot rename a file such that it would end up on another disk or partition.
100 Disk read error An error occurred when reading from disk. Typically happens when you try to read past the end of a file.
101 Disk write error Reported when the disk is full, and you’re trying to write to it.
102 File not assigned This is reported by Reset, Rewrite, Append, Rename and Erase, if you call them with an unassigned file as a parameter.
103 File not open Reported by the following functions : Close, Read, Write, Seek, EOf, FilePos, FileSize, Flush, BlockRead, and BlockWrite if the file is not open.
104 File not open for input Reported by Read, BlockRead, Eof, Eoln, SeekEof or SeekEoln if the file is not opened with Reset.
105 File not open for output Reported by write if a text file isn’t opened with Rewrite.
106 Invalid numeric format Reported when a non-numeric value is read from a text file, and a numeric value was expected.
107 Invalid enumeration Reported when a text representation of an enumerated constant cannot be created in a call to str or write(ln).
150 Disk is write-protected (Critical error)
151 Bad drive request struct length (Critical error)
152 Drive not ready (Critical error)
154 CRC error in data (Critical error)
156 Disk seek error (Critical error)
157 Unknown media type (Critical error)
158 Sector Not Found (Critical error)
159 Printer out of paper (Critical error)
160 Device write fault (Critical error)
161 Device read fault (Critical error)
162 Hardware failure (Critical error)
200 Division by zero The application attempted to divide a number by zero.
201 Range check error If you compiled your program with range checking on, then you can get this error in the following cases:

  1. An array was accessed with an index outside its declared range.
  2. Trying to assign a value to a variable outside its range (for instance an enumerated type).
202 Stack overflow error The stack has grown beyond its maximum size (in which case the size of local variables should be reduced to avoid this error), or the stack has become corrupt. This error is only reported when stack checking is enabled.
203 Heap overflow error The heap has grown beyond its boundaries. This is caused when trying to allocate memory explicitly with New, GetMem or ReallocMem, or when a class or object instance is created and no memory is left. Please note that, by default, Free Pascal provides a growing heap, i.e. the heap will try to allocate more memory if needed. However, if the heap has reached the maximum size allowed by the operating system or hardware, then you will get this error.
204 Invalid pointer operation You will get this in several cases:

  • if you call Dispose or Freemem with an invalid pointer
  • in case New or GetMem is called, and there is no more memory available. The behavior in this case depends on the setting of ReturnNilIfGrowHeapFails. If it is True, then Nil is returned. if False, then runerror 204 is raised.
205 Floating point overflow You are trying to use or produce real numbers that are too large.
206 Floating point underflow You are trying to use or produce real numbers that are too small.
207 Invalid floating point operation Can occur if you try to calculate the square root or logarithm of a negative number.
210 Object not initialized When compiled with range checking on, a program will report this error if you call a virtual method without having called its object’s constructor.
211 Call to abstract method Your program tried to execute an abstract virtual method. Abstract methods should be overridden, and the overriding method should be called.
212 Stream registration error This occurs when an invalid type is registered in the objects unit.
213 Collection index out of range You are trying to access a collection item with an invalid index (objects unit).
214 Collection overflow error The collection has reached its maximal size, and you are trying to add another element (objects unit).
215 Arithmetic overflow error This error is reported when the result of an arithmetic operation is outside of its supported range. Contrary to Turbo Pascal, this error is only reported for 32-bit or 64-bit arithmetic overflows. This is due to the fact that everything is converted to 32-bit or 64-bit before doing the actual arithmetic operation.
216 General Protection fault The application tried to access invalid memory space. This can be caused by several problems:

  1. Dereferencing a nil pointer.
  2. Trying to access memory which is out of bounds (for example, calling move with an invalid length).
217 Unhandled exception occurred An exception occurred, and there was no exception handler present. The sysutils unit installs a default exception handler which catches all exceptions and exits gracefully.
218 Invalid value specified Error 218 occurs when an invalid value was specified to a system call, for instance when specifying a negative value to a seek() call.
219 Invalid typecast Thrown when an invalid typecast is attempted on a class using the as operator. This error is also thrown when an object or class is typecast to an invalid class or object and a virtual method of that class or object is called. This last error is only detected if the -CR compiler option is used.
222 Variant dispatch error No dispatch method to call from variant.
223 Variant array create The variant array creation failed. Usually when there is not enough memory.
224 Variant is not an array This error occurs when a variant array operation is attempted on a variant which is not an array.
225 Var Array Bounds check error This error occurs when a variant array index is out of bounds.
227 Assertion failed error An assertion failed, and no AssertErrorProc procedural variable was installed.
229 Safecall error check This error occurs is a safecall check fails, and no handler routine is available.
231 Exception stack corrupted This error occurs when the exception object is retrieved and none is available.
232 Threads not supported Thread management relies on a separate driver on some operating systems (notably, Unixes). The unit with this driver needs to be specified on the uses clause of the program, preferably as the first unit (cthreads on unix).

Add in the top of the first Pascal unit (usually the project .lpr file)

Источник

Читайте также:  Iphone обновление не до последней прошивки

Adblock
detector

gylayko

30 / 29 / 15

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

Сообщений: 449

1

15.03.2013, 14:34. Показов 17420. Ответов 14

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


поставил на закрытие формы обновление содержимого файла

Delphi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
procedure TfrmIgra.FormClose(Sender: TObject; var Action: TCloseAction);
var o:TextFile;
los, los1, los2:string[5];
begin
los:=IntToStr(match1); los1:=IntToStr(match2); los2:=IntToStr(match3);
AssignFile(o,'match.txt');
Rewrite(o);
while not eof (o) do
begin
  write(o, los);
  write(o, los1);
  write(o, los2);
end;
end;

здесь на строке while not eof (o) do выдает ошибку i/o error 104
да, я раньше открываю этот же файл и беру из него данные, но я ведь закрываю его

Delphi
1
2
3
4
5
6
7
8
9
10
11
12
AssignFile(j, 'match.txt');
Reset(j);
while not EOF(j) do
  begin
    readln(j, buf3); 
    match1:=StrToInt(buf3);
    readln(j, buf4);
    match2:=StrToInt(buf4);
    readln(j, buf5); 
    match3:=StrToInt(buf5);
  end;
CloseFile(j);

в чем может быть проблема?

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



0



Programming

Эксперт

94731 / 64177 / 26122

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

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

15.03.2013, 14:34

Ответы с готовыми решениями:

Ошибка I/O Error 104
Приветствую! Есть такой программный код (на всякий случай выделил все):

unit Unit2;

interface…

Ошибка i/0 error 104
Выдает ошибку i/0 error 104, ниже архив и как заполнить текстовый файл?

Ошибка: i/o error 104
Выдает ошибку i/o error 104
procedure TAutomation.btnSaveClick(Sender: TObject);
var
f:…

I/O error 104 в Delphi 7
У сеня возникает такая ошибка.Я делаю тестирующую программу.Я сделал одну форму на которой список…

14

angstrom

15.03.2013, 14:36

2

С командой Rewrite(o)

Delphi
1
2
3
...
while not eof (o) do
...

бессмысленна.

gylayko

30 / 29 / 15

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

Сообщений: 449

15.03.2013, 14:37

 [ТС]

3

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

С командой Rewrite(o)

Delphi
1
2
3
...
while not eof (o) do
...

бессмысленна.

в смысле?
а как тогда заносить данные в файл?

если сделать Reset, запишется пустой файл!



0



angstrom

15.03.2013, 14:56

4

С чего это вдруг?

30 / 29 / 15

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

Сообщений: 449

15.03.2013, 14:58

 [ТС]

5

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

С чего это вдруг?

как с чего? с того, что я попробовал! и сообщаю результат!



0



angstrom

15.03.2013, 15:13

6

Перестань городить чушь.

Delphi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
procedure TfrmIgra.FormClose(Sender: TObject; var Action: TCloseAction);
var
  o : TextFile;
  los, los1, los2 : String;
begin
  los := IntToStr(match1); 
  los1 := IntToStr(match2);
  los2 := IntToStr(match3);
  AssignFile(o, 'match.txt');
  Rewrite(o);
  write(o, los);
  write(o, los1);
  write(o, los2);
  CloseFile(o);
end;

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

gylayko

30 / 29 / 15

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

Сообщений: 449

15.03.2013, 16:15

 [ТС]

7

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

Перестань городить чушь.

Delphi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
procedure TfrmIgra.FormClose(Sender: TObject; var Action: TCloseAction);
var
  o : TextFile;
  los, los1, los2 : String;
begin
  los := IntToStr(match1); 
  los1 := IntToStr(match2);
  los2 := IntToStr(match3);
  AssignFile(o, 'match.txt');
  Rewrite(o);
  write(o, los);
  write(o, los1);
  write(o, los2);
  CloseFile(o);
end;

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

все, я просто не закрывал файл а не подскажешь, как выводить в следующую строку? а то оно все в одну сплошную строку записало!



0



898 / 345 / 65

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

Сообщений: 1,502

15.03.2013, 16:31

8

writeln;



0



IKosoulin

0 / 0 / 0

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

Сообщений: 11

13.12.2014, 17:37

9

Ребят, помогите мне плиз, почему при запуске exe та же ошибка 104.
Не судите строго начинающий самоучка.
Суть такова: просто окно должно постоянно обновляться от тхт файла

Delphi
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
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;
 
type
  TForm1 = class(TForm)
    Label1: TLabel;
 
    procedure FormCreate(Sender: TObject);
   private
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form1: TForm1;
  F1: textfile;
  i1: string;
  i6: integer;
 
implementation
 
{$R *.dfm}
 
procedure TForm1.FormCreate(Sender: TObject);
begin
repeat
AssignFile(F1, 'C:i1.txt');
Read(F1,i1);
Form1.Label1.Caption:=i1;
CloseFile(F1);
 
i6:=0;
until i6 = 0;
end;
 
end.



0



пофигист широкого профиля

4602 / 3062 / 850

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

Сообщений: 17,661

13.12.2014, 19:43

10

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

C:i1.txt

Что это такое?



0



0 / 0 / 0

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

Сообщений: 11

14.12.2014, 01:44

11

Сори, это просто очепятка, проблема не в этом.
#
AssignFile(F5, ‘C:i1.txt’);
#



0



пофигист широкого профиля

4602 / 3062 / 850

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

Сообщений: 17,661

14.12.2014, 01:50

12

А кто в этот файл что-то пишет?



0



IKosoulin

0 / 0 / 0

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

Сообщений: 11

14.12.2014, 10:56

13

Другая программа.
Так же переменную i1: string

Добавлено через 14 минут

Delphi
1
2
3
4
5
6
7
8
9
procedure TForm1.Button1Click(Sender: TObject);
begin
i1:='ДФ_1 Возобновлен';
Form1.Label6.Caption:='Open';
    AssignFile(F,'C:i1.txt');
    ReWrite(F);
    WriteLn(F, i1);
    CloseFile(F);
end;



0



northener

пофигист широкого профиля

4602 / 3062 / 850

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

Сообщений: 17,661

14.12.2014, 13:33

14

Невнимательно вчера посмотрел код

Delphi
1
2
3
4
AssignFile(F1, 'C:i1.txt');
Read(F1,i1);
Form1.Label1.Caption:=i1;
CloseFile(F1);

А где открытие файла?



0



IKosoulin

0 / 0 / 0

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

Сообщений: 11

14.12.2014, 16:15

15

Использую reset
Ошибка 104 пропала, прога не работает((

Delphi
1
2
3
4
5
AssignFile(F1, 'C:i1.txt');
Reset(F1);
Read(F1,i1);
Form1.Label1.Caption:=i1;
CloseFile(F1);



0



Im very new to using files and im really struggling to fix this any help would be great.
It seems that the error is coming from my read array function but not entirely
sure i am also not to sure what the 104 error really means
thanks in advance

 program ReadFromFile;


type
    lineArray = array [0..19] of String;

procedure PrintArray(lines: lineArray);
var
    i: Integer;
begin
    for i:=0 to High(lines) do
    begin
        WriteLn('Text is: ', lines[i], ' Line number is: ', i);
    end;
end;

function ReadArray(var myFile: TextFile):lineArray;
var 
    count : Integer;
    lines : lineArray;
    i: Integer;
begin
    ReadLn(myFile, count);
    for i := 0 to count do
    begin
        ReadLn(myFile, lines[i]);
    end;
    result := lines;
end;

procedure Main();
var
    myFile: TextFile;
    line: lineArray;
begin

    AssignFile(myFile, 'mytestfile.dat');
    ReWrite(myFile);
    line:=ReadArray(myFile);
    Close(myFile);

    AssignFile(myFile, 'mytestfile.dat');
    Reset(myFile);
    PrintArray(line);
    Close(myFile);
end;

begin
  Main();
end.

asked Oct 27, 2017 at 5:55

j.cole's user avatar

1

You don’t know what that error means. Neither do I off the top of my head. So, let’s look it up in the documentation and find out. Websearch takes us here: https://www.freepascal.org/docs-html/user/userap4.html

File not open for input

Reported by Read, BlockRead, Eof, Eoln, SeekEof or SeekEoln if the file is not opened with Reset.

You have your calls to open the file the wrong way round. Call Reset to open for reading, Rewrite to open for writing.

Notes:

  • Looping from 0 to count will perform count + 1 iterations. I’d expect to see you looping from 0 to count - 1.
  • You don’t check whether your array is long enough. You therefore run the risk of a buffer overrun. A dynamic array would avoid this.
  • It’s not clear why you open the file for a second time when you print the contents to the console.
  • You could have looked up the error code yourself. Please take the hint to do web search the next time you encounter an error like this.

answered Oct 27, 2017 at 7:06

David Heffernan's user avatar

David HeffernanDavid Heffernan

596k42 gold badges1055 silver badges1471 bronze badges

3

 
Steep
 
(2008-01-13 20:52)
[0]

эх… снова я…
Project raised exception class EInOutError with message «I/O error 104»

Я читаю файл — числа разделенные «;»
и заношу в StringGrid и массив.

Программа запускается — читает первые десять и вылетает

procedure TForm1.Button1Click(Sender: TObject);
var
 f: TextFile;
 s, stemp: string;
 SArray: array[0..9, 0..59] of real;
 r,c,k: integer;
begin
 if OD.Execute=true then
 begin
   AssignFile(F, OD.FileName);
   Reset(f);
   r := 0;
   //Çäåñü ÷èòàåì âåñü ôàéë
   while not eof(f) do
   begin
     c := 0;
     ReadLn(f, s);
     //Èùåì â ñòðîêå äàííûå
       Showmessage(s + "; new string; r=" + IntToStr(r) + "; c=" + IntToStr(c));
     while s<>"" do
     begin
       k := Pos(";", s); //ïîçèöèÿ
       if k=0 then k := Length(s);
       stemp := Copy( S, 1, k-1 );
         //Showmessage( stemp + "; that copy; r=" + IntToStr(r) + "; c=" + IntToStr(c) );
       //Çàíîñèì äàííûå
       SArray[r,c] := StrToFloat(stemp);
       StringGrid.Rows[r].Strings[c] := stemp;
       //óäàëÿåì çàíåñåííîå èç ñòðîêè
       Delete(S, 1, k);
       inc(c);
         //Showmessage( "S = 0" + s );
     end;
     inc(r);
   end;
   //Çäåñü çàêðûâàåì ôàéë
   CloseFile(f);
 end;
end;


 
Steep
 
(2008-01-13 20:53)
[1]

Блин! чегото я только отправляю вопрос на форум и меня озаряет :)))))

Здесь же нужно в массиве наоборот указать (или заносить :) )
SArray: array[0..59, 0..9] of real;

Всем спасибо!


 
No_Dead ©
 
(2008-01-13 20:56)
[2]

> if OD.Execute=true then

а это что?
я просто не знаю:(

а так все work, если закомментить указанную


 
Dmitry S ©
 
(2008-01-13 20:59)
[3]

OD:TOpenDialog


 
No_Dead ©
 
(2008-01-13 21:03)
[4]

> [3] Dmitry S ©   (13.01.08 20:59)

так принято сокращать? хм, не знал и в правду


 
Steep
 
(2008-01-13 21:13)
[5]


> No_Dead ©  

может и не принято — но мне так нравится :)
если он один — то я так сокращаю…..


 
Amoeba ©
 
(2008-01-14 03:13)
[6]

И в чем господа, собственно, была проблема то?


 
KilkennyCat ©
 
(2008-01-14 04:54)
[7]


> Steep   (13.01.08 21:13) [5]
>
>
> > No_Dead ©  
>
> может и не принято — но мне так нравится :)

может, тогда и так понравится, а?

if OD.Execute then


 
Смирнов
 
(2008-01-14 08:56)
[8]


> может, тогда и так понравится, а?
>
> if OD.Execute then

еще вариант
if OD.Execute <> false then


 
KilkennyCat ©
 
(2008-01-14 09:25)
[9]

if (not OD.execute) = false then — это еще круче


 
Смирнов
 
(2008-01-14 10:06)
[10]

if (not OD.execute) = (2 * 2 <> 4) then


Понравилась статья? Поделить с друзьями:
  • Run error 103 lazarus
  • Run time error 6 overflow vba excel
  • Run error 102 паскаль
  • Run time error 5941 word макросы
  • Run error 100 lazarus