Ошибка 104 паскаль

seerg0

1 / 1 / 0

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

Сообщений: 17

1

01.07.2010, 12:59. Показов 8181. Ответов 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
var
s:string;
a,b,c,d:char;
f1,f2:text;
i:integer;
begin
assign(f1,'C:f1.txt');
assign(f2,'C:f2.txt');
reset(f1);
rewrite(f2);
while not EoF(f1) do begin
readln(f1,s);
for i:=1 to length(s) do
 begin
 a:=s[i];
 b:=s[i+1];
 c:=s[i+2];
 d:=s[i+3];
 if (a=' ') and (b=c) and (d=' ') then
 delete(s,i,3);
 end;
writeln(f2,copy(s,1,length(s)));
close(f1);
close(f2);
end;
end.



0



Programming

Эксперт

94731 / 64177 / 26122

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

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

01.07.2010, 12:59

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

Ошибка, файл не открыт для ввода
Procedure InpData(Var Group:Groups; Var N:TGroup);
Var
I:Integer;
FF,GG,PP,NN,RR:Text;…

Ошибка,файл не открыт для ввода
var min,ch,code,res,i,i1,i2,max,ch1:integer;
begin
max:=0;
i:=0;
min:=0;
ch1:=30001;…

Ошибка,файл не открыт для ввода
Ошибка,файл не открыт для вводаFUNCTION F(NAME:STRING):INTEGER;
var f1:Text;
var…

Файлы (файл не открыт для ввода)
Почему выдаёт такую ошибку: ошибка ввода/вывода 104
uses
crt;
var
f:text;
b:string;
begin…

5

21 / 18 / 4

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

Сообщений: 806

01.07.2010, 13:07

2

Может эту операцию copy(s,1,length(s))); вывксти в отдельную строку, а потом в файл для записа его записать, может так получится?



0



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

64288 / 47587 / 32739

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

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

01.07.2010, 13:10

3

sergei3ru, А нафига после прочтения каждой строки ты закрываешь файлы?



0



21 / 18 / 4

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

Сообщений: 806

01.07.2010, 13:11

4

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

sergei3ru, А нафига после прочтения каждой строки ты закрываешь файлы?

Где?О_о



0



Puporev

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

64288 / 47587 / 32739

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

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

01.07.2010, 13:11

5

Pascal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
while not EoF(f1) do 
  begin
   readln(f1,s);
   for i:=1 to length(s) do
    begin
     a:=s[i];
     b:=s[i+1];
     c:=s[i+2];
     d:=s[i+3];
     if (a=' ') and (b=c) and (d=' ') then
     delete(s,i,3);
    end;
   writeln(f2,copy(s,1,length(s)));
  end; 
close(f1);
close(f2);
end.



0



1 / 1 / 0

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

Сообщений: 17

01.07.2010, 13:11

 [ТС]

6

Puporev, спасибо)))) всё понял)))



1



IT_Exp

Эксперт

87844 / 49110 / 22898

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

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

01.07.2010, 13:11

6

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

599k42 gold badges1064 silver badges1481 bronze badges

3

Im очень новичок в использовании файлов и им действительно изо всех сил пытается исправить эту помощь, было бы здорово. Кажется, что ошибка исходит от моей функции чтения массива, но не совсем уверен, что я тоже не уверен, что ошибка 104 действительно означает спасибо заранее

 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.

201      : range error

215      : overflow checking when doing computation with integer

202      : overflow stack

106      : invalid numeric format

1          : invalid function number

2          : file not found

3          : path not found

4          : too many open files

5          : file access denied

6          : invalid file handle

12        : invalid file access code

15        : invalid drive number

16        : cannot remove current directory

17        : cannot rename across

18        : no more files

100      : disk read error

101      : disk write error

102      : file not assigned

103      : file not open

104      : file not open for input

105      : file not open for output

150      : disk is write protected

151      : bad drive request structure length

152      : drive not ready

154      : CRC error in data

156      : disk seek error

157      : unknown media type

158      : sector not found

159      : printer out of paper

160      : device write fault

161      : device read fault

162      : hardware failure

200      : div by zero

203      : heap overflow

204      : invalid pointer operation

205      : floating point overflow

206      : floating point underflow

207      : invalid floating point operation

208      : overlay manager not installed

209      : overlay file read error

210      : object not initialized

211      : call to abstract method

212      : stream registration error

213      : collection index out of range

214      : collection overflow error

216      : general protection fault

217      : invalid operation code

227      : assertion failed

300      : file IO error

301      : non-matched array bounds

302      : non-local procedure pointer

303      : procedure pointer out of scope

304      : function not implemented

305      : breakpoint error

306      : break by ctrl/c

307      : break by ctrl/break

308      : break by other process

309      : no floating point coprocessor

310      : invalid variant type operation

Понравилась статья? Поделить с друзьями:
  • Ошибка 104 на котле аристон класс 24
  • Ошибка 104 на котле аристон как исправить ошибку
  • Ошибка 104 на газовом котле аристон
  • Ошибка 104 калина
  • Ошибка 104 делфи