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;

Connect with Us