Sign in Join

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

Mailing lists / fpc-devel / 2015-10

get/put in fpc

22 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

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

Schneider

Thanks for everybody's help. I've made some progress in getting my standard Pascal programs to compile under fpc.

Now comes a big issue.

In standard Pascal, one can use get() and put() to access files. The current file object is accessed with file^. I use this in many places.

program getput(shellp, output);
var
   shellp: text; (* file used by this program *)
begin
   Assign (shellp,'shellp');
   writeln(output,'getput test is running');
   reset(shellp);
   writeln(output,'first character of shellp: ',shellp^);
end.

Free Pascal Compiler version 2.6.4 [2015/10/07] for x86_64 Copyright (c) 1993-2014 by Florian Klaempfl and others Target OS: Darwin for x86_64
Compiling getput.p
getput.p(9,56) Error: Illegal qualifier
getput.p(11) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted
Error: /sw/bin/ppcx64 returned an error exitcode (normal if you did not specify a source file to be compiled)

So shellp^ failed.

If I try instead

   get(shellp);

I get:

getput.p(12,7) Error: Identifier not found "get"
getput.p(14) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted

So get and put do not exist in fpc?

Tom

Thomas D. Schneider, Ph.D.
Senior Investigator
National Institutes of Health
National Cancer Institute
Center for Cancer Research
Gene Regulation and Chromosome Biology Laboratory
Molecular Information Theory Group
Frederick, Maryland 21702-1201

https://schneider.ncifcrf.gov (current link)
https://alum.mit.edu/www/toms (permanent link)

Reply by email

Tomas Hajny
to Schneider

On Fri, October 9, 2015 19:39, Schneider wrote:
.
.

In standard Pascal, one can use get() and put() to access files. The current file object is accessed with file^. I use this in many places.

.
.

Show quoted text 23 lines
Free Pascal Compiler version 2.6.4 [2015/10/07] for x86_64 Copyright (c) 1993-2014 by Florian Klaempfl and others Target OS: Darwin for x86_64 Compiling getput.p getput.p(9,56) Error: Illegal qualifier getput.p(11) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted Error: /sw/bin/ppcx64 returned an error exitcode (normal if you did not specify a source file to be compiled) So shellp^ failed. If I try instead get(shellp); I get: getput.p(12,7) Error: Identifier not found "get" getput.p(14) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted So get and put do not exist in fpc?

Have you compiled your code with -Miso command line parameter as already suggested by someone else? I assume that unit iso7185 providing these procedures is then automatically included. If not, you can certainly add this unit to your uses clause manually.

Second, as also mentioned by Jonas, the part of ISO standard support related to file handling has been only fixed recently and is not available in any released version. You might be able to build a newer compiler version from the sources if needed, although I cannot judge how easy or difficult that may get on your platform of choice (but it's certainly doable). Unfortunately, I don't see any ready made snapshots available for your platform on our FTP server - that would have been an easy solution.

Tomas

Reply by email

Jonas Maebe
to Schneider: Thanks for everybody's help. I've made some progress in getting my standard Pascal…
Schneider wrote
So get and put do not exist in fpc?

Not in FPC 2.6.4. They do exist in FPC 3.0rc1, but FPC 3.0rc1 still contains a bug that makes it (wrongfully) complain about a duplicate "SHELLP" identifier with your program (and this bug will also be in the final FPC 3.0 release; it will be fixed in FPC 3.0.2 probably). If you remove the "(shellp,output)" from the program header, the program compiles and runs correctly with FPC 3.0 if you also add a "rewrite(shellp);" after the reset though.

In general, ANSI ISO Pascal support is still very new in FPC, because until now virtually everyone wanting ISO support used GPC, and FPC's developers all come from a Turbo Pascal or Delphi background.

Jonas

Reply by email

Schneider
to Tomas Hajny: . . . . Have you compiled your code with -Miso command line parameter as already…

Tomas:

Have you compiled your code with -Miso command line parameter as already suggested by someone else? I assume that unit iso7185 providing these procedures is then automatically included. If not, you can certainly add this unit to your uses clause manually.

Yes, I'm currently compiling using:

fpc -Miso -Tdarwin -Mmacpas getput.p

(This is in a script 'fpcc' so I don't forget.)

Show quoted text 7 lines
Second, as also mentioned by Jonas, the part of ISO standard support related to file handling has been only fixed recently and is not available in any released version. You might be able to build a newer compiler version from the sources if needed, although I cannot judge how easy or difficult that may get on your platform of choice (but it's certainly doable). Unfortunately, I don't see any ready made snapshots available for your platform on our FTP server - that would have been an easy solution.

Ok, that's what I suspected.

http://www.freepascal.org/
Latest News
August 25th, 2015
FPC 3.0.0-rc1 has been released!
ftp://freepascal.stack.nl/pub/fpc/beta/3.0.0-rc1
ftp://freepascal.stack.nl/pub/fpc/beta/3.0.0-rc1/i386-macosx/ ftp://freepascal.stack.nl/pub/fpc/beta/3.0.0-rc1/i386-macosx/fpc-3.0.0rc1.intel-macosx.dmg

Is that the right one for me on Mac OS X 10.10.5?

Or rather:

http://www.freepascal.org/download.var
http://www.freepascal.org/down/source/sources.var
http://sourceforge.net/projects/freepascal/files/
Looking for the latest version? Download fpc-2.6.4.intel-macosx.dmg (91.1 MB) http://sourceforge.net/projects/freepascal/files/latest/download?source=files

?

Tom

Thomas D. Schneider, Ph.D.
Senior Investigator
National Institutes of Health
National Cancer Institute
Center for Cancer Research
Gene Regulation and Chromosome Biology Laboratory
Molecular Information Theory Group
Frederick, Maryland 21702-1201

https://schneider.ncifcrf.gov (current link)
https://alum.mit.edu/www/toms (permanent link)

Reply by email

Jonas Maebe
to Schneider
Schneider wrote 9 lines
http://www.freepascal.org/ Latest News August 25th, 2015 FPC 3.0.0-rc1 has been released! ftp://freepascal.stack.nl/pub/fpc/beta/3.0.0-rc1 ftp://freepascal.stack.nl/pub/fpc/beta/3.0.0-rc1/i386-macosx/ ftp://freepascal.stack.nl/pub/fpc/beta/3.0.0-rc1/i386-macosx/fpc-3.0.0rc1.intel-macosx.dmg Is that the right one for me on Mac OS X 10.10.5?

Yes, but note that since this a dmg installer rather than a fink package, you will not be able to easily uninstall it afterwards should you wish to do so (there is no problem with having multiple FPC versions installed concurrently and the final FPC 3.0 installer will overwrite the FPC 3.0rc1 files, but it's just something to keep in mind).

Jonas

Reply by email

Schneider
to Jonas Maebe: Not in FPC 2.6.4. They do exist in FPC 3.0rc1, but FPC 3.0rc1 still contains a bug that…

Jonas:

Show quoted text 11 lines
Not in FPC 2.6.4. They do exist in FPC 3.0rc1, but FPC 3.0rc1 still contains a bug that makes it (wrongfully) complain about a duplicate "SHELLP" identifier with your program (and this bug will also be in the final FPC 3.0 release; it will be fixed in FPC 3.0.2 probably). If you remove the "(shellp,output)" from the program header, the program compiles and runs correctly with FPC 3.0 if you also add a "rewrite(shellp);" after the reset though. In general, ANSI ISO Pascal support is still very new in FPC, because until now virtually everyone wanting ISO support used GPC, and FPC's developers all come from a Turbo Pascal or Delphi background.

Thanks for the background.

With 400+ programs, unless I can automate fixes it's not going to be feasible. (The assigment could probably be done by rebuilding the source automatically.)

The issue for me is that I use (almost) strictly standard Pascal and I could do that using GPC. But GPC on Mac OS X died with the latest Mac "upgrade" to 10.10.5. The translator p2c now also fails. This puts me in a bad position because I rely on these programs to do my science. I'm glad to know that fpc is being developed to handle ISO support now!!

Looks like I'll have to wait. Is there an announcement list I could sign up for to get the news when FPC 3.0.2 comes out?

Tom

Thomas D. Schneider, Ph.D.
Senior Investigator
National Institutes of Health
National Cancer Institute
Center for Cancer Research
Gene Regulation and Chromosome Biology Laboratory
Molecular Information Theory Group
Frederick, Maryland 21702-1201

https://schneider.ncifcrf.gov (current link)
https://alum.mit.edu/www/toms (permanent link)

Reply by email

Schneider
to Jonas Maebe

Jonas:

Yes: http://lists.freepascal.org/mailman/listinfo/fpc-announce It is generally only used to send out announcements of new versions.

Done, thanks!

Tom

Thomas D. Schneider, Ph.D.
Senior Investigator
National Institutes of Health
National Cancer Institute
Center for Cancer Research
Gene Regulation and Chromosome Biology Laboratory
Molecular Information Theory Group
Frederick, Maryland 21702-1201

https://schneider.ncifcrf.gov (current link)
https://alum.mit.edu/www/toms (permanent link)

Reply by email

Ewald
to Schneider: Tomas: Yes, I'm currently compiling using: fpc -Miso -Tdarwin -Mmacpas getput.p (This…
Schneider wrote
Yes, I'm currently compiling using: fpc -Miso -Tdarwin -Mmacpas getput.p

I don't know how correct that command line is since you specify two syntax modes: iso (-Miso) and macpas (-Mmacpas). One of those will probably take precedence over the other. Judging from your other messages, you are interested in the iso mode, so try leaving out the -Mmacpas?

Just a suggestion, I'm no expert on the compiler.

Ewald

Reply by email

Sven Barth
to Schneider: Tomas: Yes, I'm currently compiling using: fpc -Miso -Tdarwin -Mmacpas getput.p (This…
"Schneider" wrote 11 lines
Tomas: > Have you compiled your code with -Miso command line parameter as already > suggested by someone else? I assume that unit iso7185 providing these > procedures is then automatically included. If not, you can certainly add > this unit to your uses clause manually. Yes, I'm currently compiling using: fpc -Miso -Tdarwin -Mmacpas getput.p

You should only pass one of the major modes (which are "fpc", "tp", "iso", "objfpc", "macpas", "delphi" and "delphiunicode") while you can use multiple of the minor modeswitches (I don't know them all by heart so I won't list them here ^^ ).

Regards,
Sven

Reply by email

Sven Barth
to Schneider: Jonas: Thanks for the background. With 400+ programs, unless I can automate fixes it's…
"Schneider" wrote 10 lines
With 400+ programs, unless I can automate fixes it's not going to be feasible. (The assigment could probably be done by rebuilding the source automatically.) The issue for me is that I use (almost) strictly standard Pascal and I could do that using GPC. But GPC on Mac OS X died with the latest Mac "upgrade" to 10.10.5. The translator p2c now also fails. This puts me in a bad position because I rely on these programs to do my science. I'm glad to know that fpc is being developed to handle ISO support now!!

I have to admit that I'm quite impressed that you're using only Standard Pascal (I personally wouldn't want to miss many features of the modern dialects ;) ). In addition you might be the biggest ISO user of FPC yet :) (which will hopefully help to find more bugs in that mode ;) ) Out of interest: are you interested in any Extended Pascal features?

Regards,
Sven

Reply by email

Schneider
to Sven Barth: You should only pass one of the major modes (which are "fpc", "tp", "iso", "objfpc",…

Sven:

Show quoted text 6 lines
> fpc -Miso -Tdarwin -Mmacpas getput.p You should only pass one of the major modes (which are "fpc", "tp", "iso", "objfpc", "macpas", "delphi" and "delphiunicode") while you can use multiple of the minor modeswitches (I don't know them all by heart so I won't list them here ^^ ).

Ok, I switched to:
fpc -Miso -Tdarwin $program.p

That worked. Not clear whether -Tdarwin should stay ...

Tom

Thomas D. Schneider, Ph.D.
Senior Investigator
National Institutes of Health
National Cancer Institute
Center for Cancer Research
Gene Regulation and Chromosome Biology Laboratory
Molecular Information Theory Group
Frederick, Maryland 21702-1201

https://schneider.ncifcrf.gov (current link)
https://alum.mit.edu/www/toms (permanent link)

Reply by email

Schneider
to Sven Barth: I have to admit that I'm quite impressed that you're using only Standard Pascal (I…

Sven:

I have to admit that I'm quite impressed that you're using only Standard Pascal (I personally wouldn't want to miss many features of the modern dialects ;) ).

Well, sometimes it's tempting. The only thing that I do violate for some programs is getting the date and time. That's not standard, so I put them into modules that can be replaced automatically (my 'module' program does 'insertions' at the text level).

In addition you might be the biggest ISO user of FPC yet :) (which will hopefully help to find more bugs in that mode ;) )

Well, assuming that it gets off the ground and I can compile my programs ...

Out of interest: are you interested in any Extended Pascal features?

I've been programming in Pascal for more than 30 years. The code has survived numerous computer and operating system switches because I didn't rely on computer- or compiler-specific features. So I'm not at all inclined to trap the programs. These features would have to be available in all Pascal compilers ... but the p2c translator is unlikely to support them and the original author is not responding. So it looks like p2c depends on me for now ... and it's dead Jim (on a Mac).

Tom

Thomas D. Schneider, Ph.D.
Senior Investigator
National Institutes of Health
National Cancer Institute
Center for Cancer Research
Gene Regulation and Chromosome Biology Laboratory
Molecular Information Theory Group
Frederick, Maryland 21702-1201

https://schneider.ncifcrf.gov (current link)
https://alum.mit.edu/www/toms (permanent link)

Reply by email

Ralf Quint
to Schneider
Schneider wrote 9 lines
I've been programming in Pascal for more than 30 years. The code has survived numerous computer and operating system switches because I didn't rely on computer- or compiler-specific features. So I'm not at all inclined to trap the programs. These features would have to be available in all Pascal compilers ... but the p2c translator is unlikely to support them and the original author is not responding. So it looks like p2c depends on me for now ... and it's dead Jim (on a Mac).

I am programming in Pascal for 39 years now, starting around June/Juli '76 on a Wirth compiler implementation for a PDP-8. That is probably the only time I have used a "standard" compiler for Pascal. All other implementation of Pascal I have used since had been far ahead of what became ISO Pascal, including UCSD Pascal (including Apple Pascal) and later Turbo/Borland Pascal/Delphi. Even Metaware Professional Pascal, which was probably as close to ISO as it has been for me since, allowed for more sane features to make it actually usable. And we used it back in the late '80s/early '90s only to generate more optimized 386 math code for the CAD software we developed, as it had one hell of a 80386 optimizer build in, which a lot of times was beating attempts to produce better code by hand in assembler...

Avoiding computer/compiler specific features by sticking to ISO/GPC is just what gets you "trapped" in the days of punch cards and terminal printer output.

Ralf

---
This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

Reply by email

Sven Barth
to Schneider: Sven: Ok, I switched to: fpc -Miso -Tdarwin $program.p That worked. Not clear whether…
"Schneider" wrote 14 lines
Sven: > > fpc -Miso -Tdarwin -Mmacpas getput.p > > You should only pass one of the major modes (which are "fpc", "tp", > "iso", "objfpc", "macpas", "delphi" and "delphiunicode") while you can > use multiple of the minor modeswitches (I don't know them all by heart > so I won't list them here ^^ ). Ok, I switched to: fpc -Miso -Tdarwin $program.p That worked. Not clear whether -Tdarwin should stay ...

Since you're compiling on Mac OS X you don't need that. It's only if you compile for a different target than the one you're on (that's the simple version, but that should be sufficient for now ;) ).

Regards,
Sven

Reply by email

Sven Barth
to Schneider: Sven: Well, sometimes it's tempting. The only thing that I do violate for some programs…
"Schneider" wrote 6 lines
> In addition you might be the biggest ISO user > of FPC yet :) (which will hopefully help to find more bugs in that mode > ;) ) Well, assuming that it gets off the ground and I can compile my programs ...

I hope so. And we do after all want FPC to become fully ISO compliant as well so any feedback regarding this is appreciated.

Show quoted text 12 lines
> Out of interest: are you interested in any Extended Pascal features? I've been programming in Pascal for more than 30 years. The code has survived numerous computer and operating system switches because I didn't rely on computer- or compiler-specific features. So I'm not at all inclined to trap the programs. These features would have to be available in all Pascal compilers ... but the p2c translator is unlikely to support them and the original author is not responding. So it looks like p2c depends on me for now ... and it's dead Jim (on a Mac).

Ah, ok. That's a good reason.
I only asked, because maybe we're going to add support for Extended Pascal as well and then we could have at least tried to prioritize features that you need.

Regards,
Sven

Reply by email

Schneider
to Sven Barth: Since you're compiling on Mac OS X you don't need that. It's only if you compile for a…

Sven:

Show quoted text 5 lines
> That worked. Not clear whether -Tdarwin should stay ... Since you're compiling on Mac OS X you don't need that. It's only if you compile for a different target than the one you're on (that's the simple version, but that should be sufficient for now ;) ).

Ok, good, I removed that and it still worked.

Tom

Thomas D. Schneider, Ph.D.
Senior Investigator
National Institutes of Health
National Cancer Institute
Center for Cancer Research
Gene Regulation and Chromosome Biology Laboratory
Molecular Information Theory Group
Frederick, Maryland 21702-1201

https://schneider.ncifcrf.gov (current link)
https://alum.mit.edu/www/toms (permanent link)

Reply by email

Schneider
to Sven Barth: I hope so. And we do after all want FPC to become fully ISO compliant as well so any…

Sven:

Show quoted text 9 lines
> > In addition you might be the biggest ISO user > > of FPC yet :) (which will hopefully help to find more bugs in that mode > > ;) ) > > Well, assuming that it gets off the ground and I can compile my > programs ... I hope so. And we do after all want FPC to become fully ISO compliant as well so any feedback regarding this is appreciated.

Fabulous! Years ago I looked at FPC and couldn't use it. I see now what I wrote on my web page:

https://alum.mit.edu/www/toms/software.html

Show quoted text 5 lines
WARNING: Free Pascal or any other Borland Turbo Pascal based compiler will NOT WORK with Delila programs. That compiler does not understand file pointers and the get() and put() functions, which are part of the original Jensen and Wirth Pascal. Unfortunately these compilers do not follow the ISO standard.

Silly that I had to figure those things out again this time ...

I only asked, because maybe we're going to add support for Extended Pascal as well and then we could have at least tried to prioritize features that you need.

Only the ability to get date and time. If the format is the same as used by GPC, then I wouldn't have to substitute modules.

https://alum.mit.edu/www/toms/delila/timegpc.html

As with GPC I need to violate the ISO to be able to call these functions. The critical code is in module readdatetime which defines where in the date and time strings various things are expected.

I'm very much looking forward to an ISO compliant FPC!!

Regards,

Tom

Thomas D. Schneider, Ph.D.
Senior Investigator
National Institutes of Health
National Cancer Institute
Center for Cancer Research
Gene Regulation and Chromosome Biology Laboratory
Molecular Information Theory Group
Frederick, Maryland 21702-1201

https://schneider.ncifcrf.gov (current link)
https://alum.mit.edu/www/toms (permanent link)

Reply by email

Sven Barth
to Schneider
"Schneider" wrote 5 lines
Sven: > > > In addition you might be the biggest ISO user > > > of FPC yet :) (which will hopefully help to find more bugs in that

mode

Show quoted text 12 lines
> > > ;) ) > > > > Well, assuming that it gets off the ground and I can compile my > > programs ... > > I hope so. And we do after all want FPC to become fully ISO compliant > as well so any feedback regarding this is appreciated. Fabulous! Years ago I looked at FPC and couldn't use it. I see now what I wrote on my web page: https://alum.mit.edu/www/toms/software.html

I can't access neither that link nor the other. I get redirected to https://schneider.ncifcrf.gov/software.html and there I get an error (don't know which one, I'm on mobile right now...).

Silly that I had to figure those things out again this time ...

But then again things have changed since then ;)

Show quoted text 8 lines
> I only asked, because maybe we're going to add support for Extended > Pascal as well and then we could have at least tried to prioritize > features that you need. Only the ability to get date and time. If the format is the same as used by GPC, then I wouldn't have to substitute modules. https://alum.mit.edu/www/toms/delila/timegpc.html

I'll tell you once I'm able to access the website ;)

I'm very much looking forward to an ISO compliant FPC!!

Me, too. Mainly for the sake of completeness though, but I do :)

Regards,
Sven

Reply by email

Schneider
to Sven Barth

Sven:

> https://alum.mit.edu/www/toms/software.html I can't access neither that link nor the other. I get redirected to https://schneider.ncifcrf.gov/software.html

The redirection is intentional. They keep changing the location of my website so I set up a permanent link through MIT. It should always point to the current location of the website.

and there I get an error (don't know which one, I'm on mobile right now...).

...

> https://alum.mit.edu/www/toms/delila/timegpc.html I'll tell you once I'm able to access the website ;)

There are certificate issues on my website here. I'm in communication with the sysadmins to hopefully fix it them ...

Tom

Thomas D. Schneider, Ph.D.
Senior Investigator
National Institutes of Health
National Cancer Institute
Center for Cancer Research
Gene Regulation and Chromosome Biology Laboratory
Molecular Information Theory Group
Frederick, Maryland 21702-1201

https://schneider.ncifcrf.gov (current link)
https://alum.mit.edu/www/toms (permanent link)

Reply by email

Sven Barth
to Schneider
Schneider wrote 10 lines
Sven: >> https://alum.mit.edu/www/toms/software.html > > I can't access neither that link nor the other. I get redirected to > https://schneider.ncifcrf.gov/software.html The redirection is intentional. They keep changing the location of my website so I set up a permanent link through MIT. It should always point to the current location of the website.

I'm not complaining about the redirection itself ;)

Show quoted text 8 lines
> and there I get an error > (don't know which one, I'm on mobile right now...). ... >> https://alum.mit.edu/www/toms/delila/timegpc.html > I'll tell you once I'm able to access the website ;) There are certificate issues on my website here. I'm in communication with the sysadmins to hopefully fix it them ...

At least on my desktop it works. Don't know if your sysadmins fixed it by now or if it's just my mobile browser that's buggy... -.-

And to answer the problem at hand: right now we don't support the TimeStamp type or the GetTimeStamp function. In FPC we have the Delphi equivalent which is the Now function which returns a TDateTime which in turn is a Double (a floating point type with double precision). In addition there is the FormatDateTime function that allows you to convert a TDateTime to a string with a formatting of your choosing. However both functions require unit SysUtils, but in ISO mode loading units is disabled... (though you can work around that by telling the compiler to load a unit using a command line switch)
The Extended Pascal functions and the type shouldn't be that hard to add however (though we'd need to add an ExtISO mode to do it by the book ;)
- or we could just add them to the System unit, then they are available for all modes, though that opens its own can of worms :/ ).

Regards,
Sven

Reply by email

Schneider
to Sven Barth

Sven:

At least on my desktop it works. Don't know if your sysadmins fixed it by now or if it's just my mobile browser that's buggy... -.-

It seems to be a mobile problem. I can replicate it so it's not fixed yet.

Show quoted text 13 lines
And to answer the problem at hand: right now we don't support the TimeStamp type or the GetTimeStamp function. In FPC we have the Delphi equivalent which is the Now function which returns a TDateTime which in turn is a Double (a floating point type with double precision). In addition there is the FormatDateTime function that allows you to convert a TDateTime to a string with a formatting of your choosing. However both functions require unit SysUtils, but in ISO mode loading units is disabled... (though you can work around that by telling the compiler to load a unit using a command line switch) The Extended Pascal functions and the type shouldn't be that hard to add however (though we'd need to add an ExtISO mode to do it by the book ;) - or we could just add them to the System unit, then they are available for all modes, though that opens its own can of worms :/ ).

Thanks for considering these possibilities.

Tom

Thomas D. Schneider, Ph.D.
Senior Investigator
National Institutes of Health
National Cancer Institute
Center for Cancer Research
Gene Regulation and Chromosome Biology Laboratory
Molecular Information Theory Group
Frederick, Maryland 21702-1201

https://schneider.ncifcrf.gov (current link)
https://alum.mit.edu/www/toms (permanent link)

Reply by email