Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: I have some errors i need help with


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Apr 6, 2018 9:46 PM Last Post By: Alex Belo
Gary Roberson

Posts: 4
Registered: 7/12/00
I have some errors i need help with  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 6, 2018 8:19 PM
Problem No. 1
With the following code
procedure TMaze.MakeMaze(width, height, exact, open);
I'm receiving the following error.
[Error] Unit1MapGenerator.pas(290): Missing parameter type
Now, I do know that in the interface portion of the program, I do have only the four parameters set, and they are set to integers, so what can be causing the error.

Problem No. 2
This one is a tough one
[Error] Unit1MapGenerator.pas(371): Incompatible types: 'Integer' and 'Extended'
allx := RandG(exact,mx2);
I know that allx is an integer and I need it to be an integer, while the RandG parameters are demanding extended identifiers. The only two commands I know of that can give me random numbers are this one or random. Truth is I'm looking for a better routine that can generate random numbers between exact and mx2.

Problem No. 3
I have both allx and exact initilized as integer variables, so why is this error being flagged
[Error] Unit1MapGenerator.pas(373): Incompatible types: 'Integer' and 'Real'
allx := allx / exact * exact - 1;
Antonio Estevez

Posts: 665
Registered: 4/12/00
Re: I have some errors i need help with  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 6, 2018 9:28 PM   in response to: Gary Roberson in response to: Gary Roberson
This is a group about C++Builder.
You should asked the question in one of de Delphi groups.

Anyway, I'll give you some comments below.

El 07/04/2018 a las 5:19, gary roberson escribió:
Problem No. 1
With the following code
procedure TMaze.MakeMaze(width, height, exact, open);
I'm receiving the following error.
[Error] Unit1MapGenerator.pas(290): Missing parameter type

You are missing the type of each parameters:
procedure TMaze.MakeMaze(width: Integer; height: Integer; exact: Integer; open: Integer);


Since all the parameters are of the same type, it can be simplified like this:
procedure TMaze.MakeMaze(width, height, exact, open: Integer);


Problem No. 2
This one is a tough one
[Error] Unit1MapGenerator.pas(371): Incompatible types: 'Integer' and 'Extended'
allx := RandG(exact,mx2);

Call the Round function to convert the real value to integer:
allx := Round(RandG(exact,mx2));

I know that allx is an integer and I need it to be an integer, while the RandG parameters are demanding extended identifiers. The only two commands I know of that can give me random numbers are this one or random. Truth is I'm looking for a better routine that can generate random numbers between exact and mx2.

Assuming that exact is less than mx2, try this:
allx := exact + Random(mx2 - exact); // allx = [exact, mx2)


If you need that mx2 to be between the random values obtained then:
allx := exact + Random(mx2 - exact + 1); // allx = [exact, mx2]


Problem No. 3
I have both allx and exact initilized as integer variables, so why is this error being flagged
[Error] Unit1MapGenerator.pas(373): Incompatible types: 'Integer' and 'Real'
allx := allx / exact * exact - 1;

You must use the div operator to divide integers. The / operator is for real numbers.
allx := allx div exact * exact - 1;


Are you sure that expression is correct?
The expression is equivalent to
allx:= allx - 1;

Use parenthesis to modify the operators precedence:
allx:= allx div (exact * exact - 1);
or
allx:= allx div (exact * exact) - 1;
Alex Belo

Posts: 626
Registered: 10/8/06
Re: I have some errors i need help with  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 6, 2018 9:46 PM   in response to: Gary Roberson in response to: Gary Roberson
Hi.

Do you know that this is c++ (cbuilder) group? ;-)

gary roberson wrote:

procedure TMaze.MakeMaze(width, height, exact, open);
I'm receiving the following error.
[Error] Unit1MapGenerator.pas(290): Missing parameter type

AFAIK Pascal always requires types of arguments (identical in both
interface and implementation sections) so the statement should be like

procedure TMaze.MakeMaze(width, height, exact, open: integer);

[Error] Unit1MapGenerator.pas(371): Incompatible types: 'Integer' and
'Extended'
allx := RandG(exact,mx2);
I know that allx is an integer and I need it to be an integer, while
the RandG parameters are demanding extended identifiers.

According to documentation RandG exists in 3 flavors:

function RandG(Mean, StdDev: Single): Single; overload;
function RandG(Mean, StdDev: Double): Double; overload;
function RandG(Mean, StdDev: Extended): Extended; overload;

AFAIUI Passing integer as argument does not provide enough information
to compiler what version to use.

I have both allx and exact initilized as integer variables, so why is
this error being flagged [Error] Unit1MapGenerator.pas(373):
Incompatible types: 'Integer' and 'Real'
allx := allx / exact * exact - 1;

There are 2 incompatible types of division in Pascal: real ("/"
operator) and integer ("div" operator). You can not use "/" with
integer operands, use appropriate operator or explicit type conversion.

--
Alex
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02