ShowFraction program, error message 
Author Message
 ShowFraction program, error message

Hi, is a program that has the function of only showing the faction. I get a
error message in line 16 saying: Types of actual and formal var parameters
must be identical. I don't know what is wrong, I have tried putting
operators in between the apostrophes, but that doesn't work. Does anyone
know what I'm doing wrong? Or is it just a mistyping error from my side?

Thank you
Johan

PROGRAM ShowFractions;

USES
 Fraction;

VAR
 a, b, c : Fraction.Typ;

PROCEDURE ShowAssign( var Result: Fraction.Typ;
      Fract1: Fraction.Typ;
      Operator: char;
      Fract2: Fraction.Typ);
begin
 Fraction.Assign(Result, Fract1, Operator, Fract2);
 Fraction.Write(output,Fract1);
 write(output, '  ', Operator, '  ');
 Fraction.Write(output, Fract2);
 write(output, '=');
 Fraction.Write(output, Result);
 writeln(output);
end; { ShowAssign}

BEGIN { main }
 Fraction.Initialize(a, 3, 2);
 Fraction.Initialize(b, 8, 3);
 ShowAssign(c, a, '+', b);
 ShowAssign(c, a, '-', b);
 ShowAssign(c, a, '*', b);
 ShowAssign(c, a, '/', b);
END. { main }



Wed, 18 Jun 1902 08:00:00 GMT  
 ShowFraction program, error message


Quote:

>Hi, is a program that has the function of only showing the faction. I get a
>error message in line 16 saying: Types of actual and formal var parameters
>must be identical. I don't know what is wrong, I have tried putting
>operators in between the apostrophes, but that doesn't work. Does anyone
>know what I'm doing wrong? Or is it just a mistyping error from my side?

As we don't know how many blank lines precede PROGRAM, we don't know
which *is* line 16; and you should also indicate the cursor position,
which marks the spot at which the compiler ceased to be content.

And as we don't have unit Fraction either, it's hard to tell.  One
thought : is the first parameter of Fraction.Write a var parameter?

For a compile error in ShowFractions, we only need the interface section
of Fraction

--

 <URL: http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
 <URL: ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ;
 <URL: http://www.merlyn.demon.co.uk/clpb-faq.txt> Pedt Scragg: c.l.p.b. mFAQ.



Wed, 18 Jun 1902 08:00:00 GMT  
 ShowFraction program, error message

Quote:

> Hi, is a program that has the function of only showing the faction. I get a
> error message in line 16 saying: Types of actual and formal var parameters
> must be identical. I don't know what is wrong, I have tried putting
> operators in between the apostrophes, but that doesn't work. Does anyone

It would help if I could tell which line Line 16 is. It looks to me as if
that would be the line that says

write(output, ' ', Operator, ' ');

Has 'output' been chosen as the name of a file variable? If so it is a poor
choice, but the problem is most likely that it is not of type text. If not,
then it looks as if you are trying to use the standard output file, which is
also a bad idea; remove the "output" from all write() and writeln()
statements in that case.

On the other hand, if line 16 is one of the Fraction.Write statements then
there's an incompatibility between the declaration of Fraction.Write and the
syntax with which you're calling it. Is Fraction your unit, or someone
else's? Do you have access to the source code for it?

In this case the same problems with "output" may well be to blame; otherwise
you will need to check the declaration of Fraction.Write.

Incidentally, Fraction.Typ is a *really, really* bad choice of type
identifier. In fact I'm surprised it compiled. Unless "typ" is the actual
type identifier and you're indicating which unit it comes from, which is
almost certainly even worse.

Having said all that, the declaration of the Fraction object would probably
make things clearer. But if I had to put money on it, I'd suspect something
screwy happening with "output".

--
______________________________________________________________________
     The Scarlet Manuka,      |        Nitpickers' Party motto:
  Pratchett Quoter At Large,  |  "He who guards his lips guards his
 First Prophet of Bonni, is:  |  soul, but he who speaks rashly will

______________________________|_______________________________________



Wed, 18 Jun 1902 08:00:00 GMT  
 ShowFraction program, error message
Sacha
Yes, the line is

write(output, ' ', operator, ' ');

I have tried all your advice, but with no luck. Yes, the Fraction Unit is
mine. What it actually is, I have both these programs in a textbook. I typed
them both in as per thee book, but it doesn't want to compile. I am trying
to learn more about Units and data abstraction, but with examples like this,
I don't get very far.

Thanks for your time.
Regards
Johan



Quote:

> > Hi, is a program that has the function of only showing the faction. I
get a
> > error message in line 16 saying: Types of actual and formal var
parameters
> > must be identical. I don't know what is wrong, I have tried putting
> > operators in between the apostrophes, but that doesn't work. Does anyone

> It would help if I could tell which line Line 16 is. It looks to me as if
> that would be the line that says

> write(output, ' ', Operator, ' ');

> Has 'output' been chosen as the name of a file variable? If so it is a
poor
> choice, but the problem is most likely that it is not of type text. If
not,
> then it looks as if you are trying to use the standard output file, which
is
> also a bad idea; remove the "output" from all write() and writeln()
> statements in that case.

> On the other hand, if line 16 is one of the Fraction.Write statements then
> there's an incompatibility between the declaration of Fraction.Write and
the
> syntax with which you're calling it. Is Fraction your unit, or someone
> else's? Do you have access to the source code for it?

> In this case the same problems with "output" may well be to blame;
otherwise
> you will need to check the declaration of Fraction.Write.

> Incidentally, Fraction.Typ is a *really, really* bad choice of type
> identifier. In fact I'm surprised it compiled. Unless "typ" is the actual
> type identifier and you're indicating which unit it comes from, which is
> almost certainly even worse.

> Having said all that, the declaration of the Fraction object would
probably
> make things clearer. But if I had to put money on it, I'd suspect
something
> screwy happening with "output".

> --
> ______________________________________________________________________
>      The Scarlet Manuka,      |        Nitpickers' Party motto:
>   Pratchett Quoter At Large,  |  "He who guards his lips guards his
>  First Prophet of Bonni, is:  |  soul, but he who speaks rashly will

> ______________________________|_______________________________________



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Help:Record/Key Deleted message and Error message Numbers

2. Conflicting error message formats from SQL Server 2000

3. Date error message and focusing in TDBgrid

4. "File is Locked" error message

5. Message Error Older Version

6. DBE Error Messages

7. Mysterious error message

8. BDE error message 15880

9. disable error messages from IDE

10. Operation Not Applicable - Error Message

11. Invalid Variable Reference error message

12. HELP: "Error in Symbol File" message

 

 
Powered by phpBB® Forum Software