График Lazarus / Pascal
На данный момент выдает две ошибки:
unit2.pas(38,59) Error: Type identifier expectedunit2.pas(38,59) Error: Syntax error, ";" expected but "ARRAY" found
Пробовал так же TArrayOfDouble, но так же выдает ошибку, возможно есть и другие ошибки
unit Unit2;
{$mode ObjFPC}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Menus, StdCtrls,
TAGraph, TASeries, Math, Unit3;
type
TForm2 = class(TForm)
ButtonNextPage: TButton;
Chart1: TChart;
Chart1BarSeries1: TBarSeries;
procedure DrawHistogram(const StudentData: TStrings);
private
FLocalData: TStrings;
public
constructor Create(AOwner: TComponent); override;
end;
var
Form2: TForm2;
implementation
{$R *.lfm}
function IntArrayToDouble(const IntArr: array of Integer): array of Double;
var
I: Integer;
begin
SetLength(Result, Length(IntArr));
for I := Low(IntArr) to High(IntArr) do
Result[I] := IntArr[I];
end;
constructor TForm2.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FLocalData := TStringList.Create;
end;
procedure TForm2.DrawHistogram(const StudentData: TStrings);
var
i: integer;
cValues, pValues: array of integer;
begin
SetLength(cValues, StudentData.Count);
SetLength(pValues, StudentData.Count);
for i := 0 to Pred(StudentData.Count) do
begin
case Copy(StudentData.Strings[i], Pos('|', StudentData.Strings[i])+1, Length(StudentData.Strings[i])) of
'C': Inc(cValues[i]);
'P': Inc(pValues[i]);
end;
end;
with Chart1 do
begin
Title.Text.Clear;
Title.Text.Add('Распределение пакетов среди студентов');
Chart1BarSeries1.Clear;
Chart1BarSeries1.BarWidthPercent := 25;
Chart1BarSeries1.Add(Sum(cValues), 'CorelDRAW');
Chart1BarSeries1.Add(Sum(pValues), 'Photoshop');
end;
end;
end.
Ответы (1 шт):
Автор решения: Kromster
→ Ссылка
Если я верно помню, запись такого типа не допускается:
function IntArrayToDouble: array of Double;
Вам надо объявить тип:
type
TArrayDouble = array of Double;
и использовать его:
function IntArrayToDouble: TArrayDouble;