Board index » delphi » Timo Salvi's FAQ Question #73 Questioned!

Timo Salvi's FAQ Question #73 Questioned!

The following two pieces of code were taken from Timo Salvi's FAQ
Question #73, concerning how to write and compile units.

Program #1...

unit faq73;  {This unit is named at the DOS prompt 'faq73.pas'}

interface       {The interface section lists definitions and routines that
function SUMFN(a, b: real): real; {are available to other programs or units}

{The implementation section contains the actual unit program}

implementation
function SUMFN(a, b: real): real;
begin
  sumfn := a + b;
end;
end.

...End Program #1

Program #2...

program main;  {This program is named at the DOS prompt 'faq73prg.pas'}

uses faq73;

procedure TEST;
var
  x, y, z: real;

begin
  x := 12.34;
  y := 56.78;
  z := SUMFN(x,y);
  writeln(z);
end;

begin
  TEST;
end.

...End Program #2

To compile the unit I typed 'bpc /cd FAQ73.PAS' and it created a file called
'FAQ73.TPU'.

With the second section I typed 'bpc /cd FAQ73PRG.PAS' and I get the error
message...

Borland Pascal  Version 7.0  Copyright (c) 1983,92 Borland International
FAQ73PRG.PAS(1)
FAQ73PRG.PAS(1)
FAQ73PRG.PAS(12): Error 3: Unknown identifier.
  z := SUMFN(x,y);
       ^

---
As far as I can tell everything should be working correctly since I did type
the examples in exactly as they were listed in the FAQ.  If anyone can help
me figure out this small step onto the Turbo Pascal learning curve it would
be greatly appreciated.

Dan Geiser <dgei...@lansoft.com>

 

Re:Timo Salvi's FAQ Question #73 Questioned!


In article <95Aug02123453.amccb...@IH.USA.Com>,
Quote
Dan Geiser <dgei...@lansoft.com> wrote:

:The following two pieces of code were taken from Timo Salvi's FAQ

:Question #73, concerning how to write and compile units.

The code in the FAQ is ok. Use an editor to cut from the actual faq
file to avoid subtle errors. Don't retype. I just checked to make
sure taht it works as claimed.

:Borland Pascal  Version 7.0  Copyright (c) 1983,92 Borland International
:FAQ73PRG.PAS(1)
:FAQ73PRG.PAS(1)
:FAQ73PRG.PAS(12): Error 3: Unknown identifier.
:  z := SUMFN(x,y);
:       ^

R:\FAQ73.PAS(16)                          
16 lines, 61 bytes code, 0 bytes data.    
R:\FAQ73PRG.PAS(14)                            
14 lines, 4160 bytes code, 670 bytes data.

   All the best, Timo

....................................................................
Prof. Timo Salmi   Co-moderator of news:comp.archives.msdos.announce
Moderating at ftp:// & http://garbo.uwasa.fi archives  193.166.120.5
Department of Accounting and Business Finance  ; University of Vaasa
t...@uwasa.fi http://uwasa.fi/~ts BBS 961-3170972; FIN-65101,  Finland

Re:Timo Salvi's FAQ Question #73 Questioned!


On Wed Aug  2, dgei...@lansoft.com (Dan Geiser) wrote:

Quote

>unit faq73;  {This unit is named at the DOS prompt 'faq73.pas'}

>interface       {The interface section lists definitions and routines that

  look way out to the end of the above line for the missing                 }

Quote
>function SUMFN(a, b: real): real; {are available to other programs or units}

>{The implementation section contains the actual unit program}

>implementation
>function SUMFN(a, b: real): real;
>begin
>  sumfn := a + b;
>end;
>end.

As Timo says, cut and paste and do not add your own comments
if you want the code to work.

Brent
--
Brent Beach, Victoria, BC

Other Threads