### Bookstore

 Computer Math and Games in Pascal (preview) Lazarus Handbook

### Author Topic: help pls  (Read 488 times)

#### TimonKO

• Newbie
• Posts: 2
##### help pls
« on: December 19, 2022, 09:50:13 am »
Hello, please, anyone, help to solve this problem...
Code:

unit Unit1;

{\$mode objfpc}{\$H+}

interface

uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,
TAGraph, TASeries, TAFuncSeries, TAMultiSeries;

type

{ TForm1 }

TForm1 = class(TForm)
BuildGraph: TButton;
Chart1: TChart;
Chart1BubbleSeries1: TBubbleSeries;
Chart1ConstantLine1: TConstantLine;
Chart1LineSeries1: TLineSeries;
AverageNumber: TEdit;
Chart1LinePoint: TLineSeries;
FarthestFromAverage: TEdit;
Elements: TMemo;
ElementsLabel: TLabel;
AverageLabel: TLabel;
FarthestLabel: TLabel;
procedure BuildGraphClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private

public

end;

var
Form1: TForm1;
Elements: TMemo;
AverageNumber: TEdit;
FarthestFromAverage: TEdit;
BuildGraph: TButton;

implementation
{\$R *.lfm}

{ TForm1 }

const N = 35;
var
a: array [1..N] of integer;
average: real;
farthest: integer;
farthestIndex: integer;

procedure TForm1.FormCreate(Sender: TObject);
var
i: integer;
sum: integer = 0;
farthestModule: integer = 0;
module: integer = 0;

begin
Randomize;
for i:=1 to N do
begin
a := Random(50) + 40;
sum := sum + a;
end;
for i:=1 to N do

average := sum / N;
AverageNumber.Text := FloatToStr(average);

for i:=1 to N do
begin
module := abs(round(average - a));
if (module > farthestModule) then
begin
farthestModule := module;
farthest := a;
farthestIndex := i;
end;
end;
FarthestFromAverage.Text := IntToStr(farthest);
end;

procedure TForm1.BuildGraphClick(Sender: TObject);
var x: integer;
begin
Chart1LineSeries1.SeriesColor := clRed;
Chart1ConstantLine1.SeriesColor := clBlue;
Chart1LinePoint.ShowPoints := True;

for x:=1 to N do
• );

Chart1ConstantLine1.Position := average;
end;

end.

#### KodeZwerg

• Hero Member
• Posts: 1150
##### Re: help pls
« Reply #1 on: December 19, 2022, 10:27:21 am »
You are missing in that .lpr file to include "Unit1" in the uses section.
« Last Edit: Tomorrow at 31:76:97 by KodeZwerg »

#### PascalDragon

• Hero Member
• Posts: 4951
• Compiler Developer
##### Re: help pls
« Reply #2 on: December 19, 2022, 10:15:29 pm »
Hello, please, anyone, help to solve this problem...
Code:

When posting code please use [code][/code] tags. This avoids the forum software interpreting certain character sequences and makes it easier to view.

#### TimonKO

• Newbie
• Posts: 2
##### Re: help pls
« Reply #3 on: December 21, 2022, 11:58:54 am »
You are missing in that .lpr file to include "Unit1" in the uses section.
how to include it into .lpr file

#### dseligo

• Hero Member
• Posts: 953
##### Re: help pls
« Reply #4 on: December 21, 2022, 12:32:39 pm »
You are missing in that .lpr file to include "Unit1" in the uses section.
how to include it into .lpr file

Add it in the .lpr's uses section:
Code: Pascal  [Select][+][-]
1. ...
2.   Forms, tachartlazaruspkg, Unit1
3. ...

You can see .lpr file when you go to menu Project/View Project Source. There you just type your unit name like above.
« Last Edit: December 21, 2022, 12:34:57 pm by dseligo »