Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2006-04

pc -> fpc porting question: reset()

8 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

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

Michael Van Canneyt
to Daniel Franke
Daniel Franke wrote 53 lines
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.

Daniel Franke
to Michael Van Canneyt
Show quoted text 10 lines
> 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

Daniel Franke
to Michael Van Canneyt: Would become: Assign(ipedfile,'ipedfile.dat') Reset(ipedfile);…
Show quoted text 7 lines
> 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

Daniel Franke
to Michael Van Canneyt: Yes. Runtime error 2 means that the file does not exist. Michael.
Michael Van Canneyt wrote 22 lines
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

Michael Van Canneyt
to Daniel Franke: Breakpoint 1, INITILINK () at ilink51.p:6065 6065 Assign(ipedfile,'ipedfile.dat');…
Daniel Franke wrote 22 lines
> > 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.

Michael Van Canneyt
to Daniel Franke: many thanks for your fast reply! Err, I assume this also holds for…
Daniel Franke wrote 18 lines
> > 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.