pc -> fpc porting question: reset()

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

pc -> fpc porting question: reset()

Daniel Franke
Hi all.

I'm a pascal noob who was given the task to compile a couple of ancient pascal
files, originally written for "Sun Pascal pc compiler".

Since I don't know anything about pascal, fpc's error messages gave me sort of
a headache. Nevertheless, I'm almost there - but not quite. i still get loads
of these:

-- fpc error messages (begin) --
ilink51.p(6065,32) Error: Incompatible type for arg no. 2: Got "ShortString",
expected "LongInt"
ilink51.p(6066,32) Error: Incompatible type for arg no. 2: Got "ShortString",
expected "LongInt"
-- fpc error messages (end) --

These messages are always related to calls to reset:
-- ilink51.p (begin) --
6065:  reset(ipedfile,'ipedfile.dat');
6066:  reset(datafile,'datafile.dat');
-- ilink51.p (end) --
[ipedfile/datafile are of type "text"]

The fpc language manual (sec 28.9.442, p. 1109) describes reset as:
-- rtl.pdf (begin) --
Synopsis: Open file for reading
Declaration: procedure    Reset(var f: File;l: LongInt)
             procedure    Reset(var  f: File)
             procedure    Reset(var  f: TypedFile)
             procedure    Reset(var  t: Text)
-- rtl.pdf (end) --

whereas the SUN pascal reference has:
-- docs.sun.com [1] (begin) --
reset
    Pascal supports an optional second argument to the reset procedure.
    This argument gives an operating system file name.
Syntax
    reset(file, filename)

Arguments
    file is a variable having the text or file data type.
    filename is a fixed- or variable-length string, or a string constant.
-- docs.sun.com [1] (end) --


My assumption: to compile these files using fpc, I have to change any call to
reset, most likely by adding another function call afterwards.
My question: which function would that be? How to accomplish with fpc what is
done by Sun's compiler/libraries?!

With kind regards
        Daniel


[1] http://docs.sun.com/app/docs/doc/801-5055/6hvhckkgl?l=fr&a=view
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: pc -> fpc porting question: reset()

Michael Van Canneyt


On Mon, 17 Apr 2006, Daniel Franke wrote:

> Hi all.
>
> I'm a pascal noob who was given the task to compile a couple of ancient pascal
> files, originally written for "Sun Pascal pc compiler".
>
> Since I don't know anything about pascal, fpc's error messages gave me sort of
> a headache. Nevertheless, I'm almost there - but not quite. i still get loads
> of these:
>
> -- fpc error messages (begin) --
> ilink51.p(6065,32) Error: Incompatible type for arg no. 2: Got "ShortString",
> expected "LongInt"
> ilink51.p(6066,32) Error: Incompatible type for arg no. 2: Got "ShortString",
> expected "LongInt"
> -- fpc error messages (end) --
>
> These messages are always related to calls to reset:
> -- ilink51.p (begin) --
> 6065:  reset(ipedfile,'ipedfile.dat');
> 6066:  reset(datafile,'datafile.dat');
> -- ilink51.p (end) --
> [ipedfile/datafile are of type "text"]
>
> The fpc language manual (sec 28.9.442, p. 1109) describes reset as:
> -- rtl.pdf (begin) --
> Synopsis: Open file for reading
> Declaration: procedure    Reset(var f: File;l: LongInt)
>              procedure    Reset(var  f: File)
>              procedure    Reset(var  f: TypedFile)
>              procedure    Reset(var  t: Text)
> -- rtl.pdf (end) --
>
> whereas the SUN pascal reference has:
> -- docs.sun.com [1] (begin) --
> reset
>     Pascal supports an optional second argument to the reset procedure.
>     This argument gives an operating system file name.
> Syntax
>     reset(file, filename)
>
> Arguments
>     file is a variable having the text or file data type.
>     filename is a fixed- or variable-length string, or a string constant.
> -- docs.sun.com [1] (end) --
>
>
> My assumption: to compile these files using fpc, I have to change any call to
> reset, most likely by adding another function call afterwards.
> My question: which function would that be? How to accomplish with fpc what is
> done by Sun's compiler/libraries?!

> 6065:  reset(ipedfile,'ipedfile.dat');
> 6066:  reset(datafile,'datafile.dat');

Would become:

Assign(ipedfile,'ipedfile.dat')
Reset(ipedfile);

Assign(datafile,'datafile.dat');
Reset(datafile);

Michael.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: pc -> fpc porting question: reset()

Daniel Franke

> > 6065:  reset(ipedfile,'ipedfile.dat');
> > 6066:  reset(datafile,'datafile.dat');
>
> Would become:
>
> Assign(ipedfile,'ipedfile.dat')
> Reset(ipedfile);
>
> Assign(datafile,'datafile.dat');
> Reset(datafile);

Micheal,
many thanks for your fast reply!
Err, I assume this also holds for "rewrite(outfile,'outfile.dat');", i.e.
    Assign(outfile,'outfile.dat');
    rewrite(outfile);
??

Again, many thanks! Maybe there's still some leisure-time left in this day =)

Regards
        Daniel
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: pc -> fpc porting question: reset()

Daniel Franke
In reply to this post by Michael Van Canneyt


> > 6065:  reset(ipedfile,'ipedfile.dat');
> > 6066:  reset(datafile,'datafile.dat');
>
> Would become:
>
> Assign(ipedfile,'ipedfile.dat')
> Reset(ipedfile);


Breakpoint 1, INITILINK () at ilink51.p:6065
6065      Assign(ipedfile,'ipedfile.dat');
(gdb) next
6066      Reset(ipedfile);
(gdb)
Runtime error 2 at $08063C1B
  $08063C1B
  $08063EE4

It's correct behaviour to crash if the file ('ipedfile.dat' in this case) does
not exist?

        Daniel
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: pc -> fpc porting question: reset()

Michael Van Canneyt


On Mon, 17 Apr 2006, Daniel Franke wrote:

>
>
> > > 6065:  reset(ipedfile,'ipedfile.dat');
> > > 6066:  reset(datafile,'datafile.dat');
> >
> > Would become:
> >
> > Assign(ipedfile,'ipedfile.dat')
> > Reset(ipedfile);
>
>
> Breakpoint 1, INITILINK () at ilink51.p:6065
> 6065      Assign(ipedfile,'ipedfile.dat');
> (gdb) next
> 6066      Reset(ipedfile);
> (gdb)
> Runtime error 2 at $08063C1B
>   $08063C1B
>   $08063EE4
>
> It's correct behaviour to crash if the file ('ipedfile.dat' in this case) does
> not exist?

Yes. Runtime error 2 means that the file does not exist.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: pc -> fpc porting question: reset()

Michael Van Canneyt
In reply to this post by Daniel Franke


On Mon, 17 Apr 2006, Daniel Franke wrote:

>
> > > 6065:  reset(ipedfile,'ipedfile.dat');
> > > 6066:  reset(datafile,'datafile.dat');
> >
> > Would become:
> >
> > Assign(ipedfile,'ipedfile.dat')
> > Reset(ipedfile);
> >
> > Assign(datafile,'datafile.dat');
> > Reset(datafile);
>
> Micheal,
> many thanks for your fast reply!
> Err, I assume this also holds for "rewrite(outfile,'outfile.dat');", i.e.
>     Assign(outfile,'outfile.dat');
>     rewrite(outfile);
> ??

This is correct.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: pc -> fpc porting question: reset()

Daniel Franke
In reply to this post by Michael Van Canneyt
On Monday 17 April 2006 16:18, Michael Van Canneyt wrote:

> On Mon, 17 Apr 2006, Daniel Franke wrote:
> > > > 6065:  reset(ipedfile,'ipedfile.dat');
> > > > 6066:  reset(datafile,'datafile.dat');
> > >
> > > Would become:
> > >
> > > Assign(ipedfile,'ipedfile.dat')
> > > Reset(ipedfile);
> >
> > Breakpoint 1, INITILINK () at ilink51.p:6065
> > 6065      Assign(ipedfile,'ipedfile.dat');
> > (gdb) next
> > 6066      Reset(ipedfile);
> > (gdb)
> > Runtime error 2 at $08063C1B
> >   $08063C1B
> >   $08063EE4
> >
> > It's correct behaviour to crash if the file ('ipedfile.dat' in this case)
> > does not exist?
>
> Yes. Runtime error 2 means that the file does not exist.


I'm set. Thanks!

        Daniel
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: pc -> fpc porting question: reset()

Jonas Maebe-2

On 17 Apr 2006, at 16:12, Daniel Franke wrote:

>>> It's correct behaviour to crash if the file ('ipedfile.dat' in  
>>> this case)
>>> does not exist?
>>
>> Yes. Runtime error 2 means that the file does not exist.
>
> I'm set. Thanks!

See also
   http://www.freepascal.org/docs-html/rtl/system/ioresult.html

(in particular the example program)


Jonas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal