Recent

Author Topic: FPC built-in functions - Identifier not found  (Read 7828 times)

tpatriarche

  • Newbie
  • Posts: 4
FPC built-in functions - Identifier not found
« on: December 06, 2014, 01:23:24 am »
This may mark me as a real newbie, but...
I can't get common built-in functions such as UpperCase to work in Free Pascal 2.6.4.
I get the compiler message "Identifier not found: UpperCase"
Do I need to declare them?  Are they in a library not included with FPC?

???
TP
« Last Edit: December 06, 2014, 02:04:59 am by tpatriarche »

Basile B.

  • Guest
Re: FPC built-in functions - Identifier not found
« Reply #1 on: December 06, 2014, 03:21:46 am »
You have to put the unit name in the uses clause, e.g

Code: [Select]
uses
    sysutils;

there can be two uses clause in a pascal unit: either in the interface section or at the beginning of the implementation section. when declared in the interface section, the initialization section of the used module will be called on program start.

tpatriarche

  • Newbie
  • Posts: 4
Re: FPC built-in functions - Identifier not found
« Reply #2 on: December 20, 2014, 09:01:46 am »
Thanks...that worked.
Now I have a similar problem: "readkey" is not recognized.
Seems to me TurboPascal looked after all these background compiler tasks automatically ... but maybe I misremember!
Now I do remember why I hated Pascal!  It teaches you with an ebony ruler! >:( What was the Pascal-based language that essentially replaced it for practical programming?

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: FPC built-in functions - Identifier not found
« Reply #3 on: December 20, 2014, 11:03:31 am »
If you do a google search with "fpc readkey" you get this: http://www.freepascal.org/docs-html/rtl/crt/readkey.html

And since it is Reference for unit 'Crt', we know to put crt in uses list. And i can tell it's the same for every programming language. If you use other units you need to tell compiler which ones.

Unit like that is only used for learning oldschool pascal or maybe console apps, but not for Lazarus. No need to include it to the core.

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: FPC built-in functions - Identifier not found
« Reply #4 on: December 20, 2014, 01:15:10 pm »
Now I have a similar problem: "readkey" is not recognized.
Seems to me TurboPascal looked after all these background compiler tasks automatically ... but maybe I misremember!
Even in the old days of TP this was in unit crt.
Mind you, most people in those days automatically started writing any program with:

Code: [Select]
Program SomeProg;

uses dos, crt;
...

Bart

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11458
  • FPC developer.
Re: FPC built-in functions - Identifier not found
« Reply #5 on: December 20, 2014, 02:16:33 pm »
(just like uppercase was not default available in TP, only in dos or objects. But those old units only contain the shortstring variants afaik, so better use sysutils)

Keep in mind that FPC is a turbo pascal compatible, not an emulation. There are (intentional) differences, and more importantly, better ways of doing things.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: FPC built-in functions - Identifier not found
« Reply #6 on: December 20, 2014, 06:57:42 pm »
Thanks...that worked.
Now I have a similar problem: "readkey" is not recognized.
Seems to me TurboPascal looked after all these background compiler tasks automatically ... but maybe I misremember!
Nope, it never does. Turbo Pascal is a subset of what Free Pascal today, but Free Pascal remains compatible with Turbo Pascal. Turbo Pascal even has very bad error message that is hard to understand by most people.
Now I do remember why I hated Pascal!  It teaches you with an ebony ruler! >:( What was the Pascal-based language that essentially replaced it for practical programming?
still Pascal. Don't blame language/tool for your inability to understand. Any language with proper module support will require similar way of doing this, such automatic identifier resolving will be possible never due to namespace rule.
« Last Edit: December 21, 2014, 06:37:22 am by Leledumbo »

tpatriarche

  • Newbie
  • Posts: 4
Re: FPC built-in functions - Identifier not found
« Reply #7 on: December 20, 2014, 09:58:31 pm »
Thanks! I foolishly removed "uses crt" because it seemed obvious  ;)

My beef with Pascal generally is that it was designed as a teaching language & hence is uniquely strict in many respects and aborts the compile as soon as hits the first error.  Our S/W Co. switched to another language, similar in syntax to Pascal, but more programmer-friendly, but I can't remember the name.  Could probably find it on Wikipedia.

I'm back in Pascal because I would like to work on a Pascal version of the original Adventure game (aka The Adventure of Colossal Cave).

tpatriarche

  • Newbie
  • Posts: 4
Re: FPC built-in functions - Identifier not found
« Reply #8 on: December 20, 2014, 10:06:01 pm »
Modula(-#) was the language we switched to that I couldn't remember.  I mostly programmed in  dBase - FoxPro - Visual FoxPro but occasionally did maintenance on Pascal & Modula programs, so really am a newbie, or an oldbie.  I paid my dues, though, writing machine code (!) for an IBM 1620 and assembler in CP/M many years ago.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11458
  • FPC developer.
Re: FPC built-in functions - Identifier not found
« Reply #9 on: December 21, 2014, 01:25:18 pm »
Thanks! I foolishly removed "uses crt" because it seemed obvious  ;)

My beef with Pascal generally is that it was designed as a teaching language & hence is uniquely strict in many respects and aborts the compile as soon as hits the first error. 

Teaching language always sounds if it was meant for kindergarten-level education with a lot of colorful pics. (1968's Raspberry pi so to say)

However Pascal was meant to be used inside a math department's CS branch as a workhorse to formalize algorithms and at the same time describe an efficient implementation for an audience of students and scientists.

IOW it was not meant to teach beginners, but to teach and serve as a workhorse for hardcore CS students and Phds in an scientific environment. That is a target something most other languages can't even match.

Quote
Our S/W Co. switched to another language, similar in syntax to Pascal, but more programmer-friendly, but I can't remember the name.

Modula and Modula-2 are the direct (and very similar) successors of Pascal that unfortunately never got popular. In general they are better and were targeted at system level programming. (a reason why many embedded companies migrated to it).  I don't know Modula that well, but I know the successor Modula-2 (M2) well.

The practical difference are small though, since the advancements were relative to the original Pascal description, and not to the Pascal implementations already in use, key concepts already had been backported to Pascal before the M2 standard was formalized. (e.g. the unit system comes from that branch, and one of the other improvements is a elegant solution for which Turbo Pascal got the untyped "pointer", but functionally the same)

And worse, the Turbo Pascal branch had the great timesaver that is called the "string" type, while Modula2 was more array of char based with static buffers. (a bit like C before GNU introduced the convention that all strings should be pointers to make them "unlimited").

Modula2 did fix dangling else, and set the base level a bit higher (the many different Pascals all had extensions, but with differences between them), and had a better defined standard library (though that specification already felt outdated in 1990, let alone now)
But Modula(-2) but never got really popular because Pascal had become a workhorse in CS departments, and the UCSD Pascal boom on micros made it even more popular.

Undeserved, since M2 was better, but aside from the block structure, the improvements were more in the matter of better formalization of the standard and features than earth shattering. (specially since the more revolutionary module system was largely backported into Pascal, though it took till 1990 till that was formalized, and by then nobody cared since Turbo Pascal dominated the market and set its own standard)

« Last Edit: December 21, 2014, 01:28:34 pm by marcov »

 

TinyPortal © 2005-2018