Runtime error 105 at writeln 
Author Message
 Runtime error 105 at writeln

Hello,
I'm receiving runtime error 105 at a simple writeln('text..') statement.
The HELP function learns me 105=File not open for output, and that I should
specify "uses WinCrt", which is the case!
In that same program I read a file, composed of address records. The
writeln(...) statements before the read are working fine, the first one
after is getting a 105!
Here goes my little program :
program sortadres;
uses WinCrt;

const
max=20;

type
adr=record
    naam:string;
    straat:string;
    nummer:integer;
    gemeente:string;
    postcode:integer;
end;
rij=array[1..max] of adr;

var
bestand: file of adr;
adres:rij;
xadr:adr;
i,j,aantal:integer;

begin

  assign (bestand,'C:\unzipped\adressen.txt');
  reset (bestand);

  i:=0;
  while not eof(bestand) do
    begin
    i:=i+1;
    read(bestand,adres[i]);
    end;

  close(bestand);
  aantal:=i-1;
for i:=1 to aantal do
      writeln(adres[i].naam);
end.
-----------
What may that read(bestand,..) have caused, that I can't write to the
standard output anymore? I'am working with Turbo Pascal V1.5.
Any help will be apreciated.
Johan.



Wed, 18 Jun 1902 08:00:00 GMT  
 Runtime error 105 at writeln

Quote:

> Hello,
> I'm receiving runtime error 105 at a simple writeln('text..') statement.
> The HELP function learns me 105=File not open for output, and that I should
> specify "uses WinCrt", which is the case!
> In that same program I read a file, composed of address records. The
> writeln(...) statements before the read are working fine, the first one
> after is getting a 105!

Having tried your program (with a dummy sample), it worked quite well under
BPW 7, although I'm not sure why you don't want to display the last record.
Also, it might help to have a limit on the size of your strings - they
shouldn't all need to be up to 255 characters long, I hope!

Having said that, I note that the working writeln() statements are all to
the disk file, rather than to the CRT, so that doesn't tell us a lot. Try
putting a few writelns to the CRT in various places and see how many, if any
of them, execute. I think you will probably find it is not anything you're
doing with the disk file that causes the problem. But I can't be completely
sure of this since I can't duplicate the problem!

--
______________________________________________________________________
     The Scarlet Manuka,      |        Nitpickers' Party motto:
  Pratchett Quoter At Large,  |  "He who guards his lips guards his
 First Prophet of Bonni, is:  |  soul, but he who speaks rashly will

______________________________|_______________________________________



Wed, 18 Jun 1902 08:00:00 GMT  
 Runtime error 105 at writeln


Quote:
> Hello,
> I'm receiving runtime error 105 at a simple writeln('text..')
statement.
> The HELP function learns me 105=File not open for output, and that I
should
> specify "uses WinCrt", which is the case!
> In that same program I read a file, composed of address records. The
> writeln(...) statements before the read are working fine, the first
one
> after is getting a 105!
> Here goes my little program :
> program sortadres;
> uses WinCrt;

> const
> max=20;

> type
> adr=record
>     naam:string;
>     straat:string;
>     nummer:integer;
>     gemeente:string;
>     postcode:integer;
> end;
> rij=array[1..max] of adr;

> var
> bestand: file of adr;
> adres:rij;
> xadr:adr;
> i,j,aantal:integer;

> begin

>   assign (bestand,'C:\unzipped\adressen.txt');
>   reset (bestand);

>   i:=0;
>   while not eof(bestand) do
>     begin
>     i:=i+1;
>     read(bestand,adres[i]);

The problem might be if there are more than "max" (20) records in
"bestand".   If it tries to read a record into adres[21], who knows what
will happen?

Change "while" loop to:
    while (not(eof(bestand))) and (i < MAX) do

Quote:
>     end;

>   close(bestand);
>   aantal:=i-1;
> for i:=1 to aantal do
>       writeln(adres[i].naam);
> end.
> -----------
> What may that read(bestand,..) have caused, that I can't write to the
> standard output anymore? I'am working with Turbo Pascal V1.5.

--
Get paid to surf:
www.alladvantage.com/go.asp?refid=HAM962

Sent via Deja.com http://www.deja.com/
Before you buy.



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Runtime Error 105

2. Help!! Runtime error 105 w/ TP 1.5 for windows

3. IOResult=105 (sometimes)

4. Pascal7.0: Errorcode 105 DRINGEND

5. Heap Overflow Error - runtime error 203

6. Confusing runtime error porting to TPW

7. runtime error

8. Runtime error 216?

9. error SQL provided in runtime

10. Accessing?database?in?OCX?givces runtime error 216?on?exit

11. Object Pro Opcrt unit runtime error 200

12. Please Help - Runtime error!

 

 
Powered by phpBB® Forum Software